Creation in Java code: Description: a) Creation of a text file in the current working
Question:
Creation in Java code:
Description:
a) Creation of a text file in the current working directory of your project having marks of unspecified courses (more than 5) separated by spaces. Give the name of the text file as firstname.txt. You can see my sample file for your reference:
b) Writing a program that prompts the user to enter the file name, read the marks from the file and displays their total and average up to two decimal places. Sample output
c)]Show the contents of the file temp.txt IN YOUR PROJECT after the following program is executed
public class Test
{ public static void main(String[] args) throws java.io.IOException {
java.io.PrintWriter output = new java.io.PrintWriter("temp.txt");
output.printf("amount is %f %e\r\n", 32.32, 32.32);
output.printf("amount is %5.4f %5.4e\r\n", 32.32, 32.32);
output.printf("%6b\r\n", (1 > 2));
output.printf("%6s\r\n", "Java");
output.close(); } }
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean