subject

In the Java code below what are the errors? File fileDir = new File("C:\test");
File file = new File("C://test//test. txt");
if (fileDir. exists()) { fileDir. mkdir();
System. out. println("The directory does not exist.\nCreating directory...");
} else
{
System. out. printf("The directory does exist at this location: \n%s\n", fileDir. getAbsolutePath());
}
if (file. exists()) { System. out. println("The file does not exist.\nCreating file...");

file. createFile(); System. out. printf("The file now exists and is located here:\n%s\n", file. getAbsolutePath());

}
else { System. out. printf("The file already exists and is located here:\n%s\n", file. getAbsolutePath());
}
PrintWriter output = new PrintWriter(fileName); double amount = 456.73;
for (int i = 1; i <= 10; i++) { output. printf("Account %d:\t $%.2f" + System. getProperty("line. separator"), i, amount += 23.45);

}
output. close(); try (Scanner input = new Scanner(file)) { System. out. println("The contents of the file are listed below:");

while (input. hasNext()) { String line = input. nextLine(); System. out. println(line); }

} input. close();

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:40, silviamgarcia
Pthreads programming: create and terminate a thread write a c++ program that creates a thread. the main will display a message “hello world from the main”. the main will create a thread that will display a message “hello world from the thread” and then terminates with a call to pthread_exit()
Answers: 3
image
Computers and Technology, 23.06.2019 13:10, BrianKeokot4534
What is domain name system (dns)? allows dynamic ip address allocation so users do not have to have a preconfigured ip address to use the network converts ip addresses into domains, or identifying labels that use a variety of recognizable naming conventions the efficient coexistence of telephone, video, and data communication within a single network, offering convenience and flexibility not possible with separate infrastructures the integration of communication channels into a single service
Answers: 2
image
Computers and Technology, 23.06.2019 15:00, hunteryolanda82
Based on the current economic situation do you expect the employment demand for graduating engineers to increase or decrease? explain the basis for your answer. with a significant economic recovery, what do you think will happen to future enrollments in graduating engineering programs?
Answers: 1
image
Computers and Technology, 24.06.2019 02:00, ishmael9332
How are we able to create photographs differently than 100 years ago? explain your answer in relation to your photograph you selected.
Answers: 1
You know the right answer?
In the Java code below what are the errors? File fileDir = new File("C:\test");
File file =...

Questions in other subjects:

Konu
English, 03.01.2022 15:50