HW10
.docx
keyboard_arrow_up
School
Georgia Southern University *
*We aren’t endorsed by this school
Course
1301
Subject
Computer Science
Date
Dec 6, 2023
Type
docx
Pages
3
Uploaded by BaronBoulderSeahorse44
CSCI 1301 Homework #10
Due date: November 26, 2023 (Sunday), 11:59pm
Text File Input and Output
Write a method named createFile1 to create a file named hw10.txt.
The method takes an int
array as an input parameter and returns the file object associated with hw10.txt.
If the file
hw10.txt does not exist (if the file exists, let the method return null), write the all the numbers
from the int array into the file using text I/O.
Integers are separated by line breaks in the file.
The array of 10 random integers ranging in [0, 99] is created in the main method to test this
method. Please see the main method given in the next page. Please use the exact provided main
method in your own program.
In the same program, write another method called createFile2 to create a file named
hw10_scale.txt. The method takes the returned file object by the createFile1 method as an input
parameter and returns the file object associated with hw10_scale.txt.
If the file does not exist (if
the file exists, let the method return null), multiply all the numbers from hw10.txt by 10 and save
all the new numbers in hw10_scale.txt.
For example, if hw10.txt is
26
12
4
89
54
65
12
65
74
3
Then hw10_scale.txt should be:
260
120
40
890
540
650
120
650
740
30
Be sure that your source code compile and execute successfully.
Grading:
This assignment is worth 100 points.
Grade criteria
Maximum points
Correct result and output
Proper implementation of all features specified in the program
80
Proper style and documentation *
20
*
The requirement of proper style and documentation can be found in “Expanded
Guidelines on Programming Style and Documentation” document in the “Course Info”
module in folio.
●
Please name your class file as “HW10”.
●
For submission in Gradescope, please include the packages given below before you
submit your code or your code won’t compile.
package
homework;
import
java.io.*
;
import
java.util.Scanner;
public class
HW10 {
public
static
void
main(String[]
args
)
throws IOException
{
int
[]
randomNumbers
= new
int
[10];
for (int i = 0; i <
randomNumbers
.length; i++) {
randomNumbers
[i] = (
int
) (Math.random() * 100);
}
File
file1
= generateFile1(
randomNumbers
);
if (
file1
== null)
return
;
File
file2
= generateFile2(file1);
if (
file2
== null)
return
;
}
public static File
createFile1(
int
[]
numbers
)
throws IOException
{
//Please write your code here
}
public static File
createFile2(
File
file
)
throws IOException {
//Please write your code here
}
}
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Requested files: InClass02.java, input.txt Maximum number of files: 6
Create a simple java program that reads all the content in a .txt file, the user will enter the filename to be opened. In this case, the file will contain multiple lines of student details with each line containing a single student detail. Your task is to then create a student class that models the firstname, lastname, year of birth and gender of every student. The student class should further be able to assign every student created with a student number using a class variable[format is 2022000X, X is a number such as 1,2..] and be able to calculate the age of each student. Within the driver class add all the students read from file into an ArrayList and then print the first and last student in the list. You are additionally expected to deal with most common exceptions(See samples below)
[HINT: DO NOT PROVIDE A PATH BUT RATHER ONLY OPEN THE FILE WITH RELATIVE PATH/FILENAME]
Sample run 1:
Enter filename:…
arrow_forward
Task: Loading data from files
This exercise will require you to load some information from files and use it in your program.
scene.txt contains a description of a series of shapes and colours to draw. You need to write code to read in the file data and draw the requested shapes in the correct colour. Each line in scene.txt will contain one of the following starting keywords followed by some data:
COLOUR followed by 3 values: R, G, B
CIRCLE followed by 3 values: X, Y, RADIUS
RECT Followed by 4 values: X, Y, W, H
LINE Followed by 4 values: X1, Y1, X2, Y2
CIRCLES are defined from the center. RECT's are defined from the top left. All values are space separated, and you can assume all input is correct (no errors). Please solve this program to draw the scene.
I can't upload the file scene.txt, so I decide to screenshot a file for you.
Subject: Java Programming
arrow_forward
COMPUTER SCIENCE 130 JAVA PROGRAM
Chapter 4. Homework Assignment (read instructions carefully)
Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits):
Total: nnnnn.nnn
Average: nnnnn.nnn
Class name: FileTotalAndAverage
double_input1.txt double_input2.txt
PLEASE FIX AND MODIFY THIS JAVA SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASSES PLEASES. RIGHT NOW IT SAYS 0 OUT 3 PASSED. THE PICTURES THAT I PROVIDED PROOF THAT WHEN I UPLOAD IT TO HYPERGRADES IT FAILS TEST CASSES. THANK YOU.
import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.InputMismatchException;import java.util.Locale;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String…
arrow_forward
Put the class definition in EV.h and the implementation of the constructors and functions in EV.cpp
1. Define a class called "EV", that represents the information of an electric vehicle. The EV is defined with these
attributes: model (string), range(int), unit (string) and year (int). Functions of the EV class must perform
the following operations:
1. A default constructor which sets all the numeric instance variables to zero.
2. A constructor with 4 parameters which sets the 4 instance variables to the corresponding values passed.
3. Implement a getter function for each of the 4 instance variables that will return the value of the instance
variable. For example, the getX() function for the instance variable model must be called
getModel().
4. Implement a setter function for each instance variable that will assign to the instance variable to the
value passed. For example, the setX() function for the instance variable model must be called
setModel().
5. An info function: this function…
arrow_forward
JAVA PROGRAM
Chapter 4. Homework Assignment (read instructions carefully)
Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits):
Total: nnnnn.nnn
Average: nnnnn.nnn
Class name: FileTotalAndAverage
double_input1.txt double_input2.txt
PLEASE MODIFY THIS CODE, SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL THE TEST CASES, BECAUSE WHEN I UPLOAD IT TO HYPERGRADE IT DOES NOT PASS THE TEST CASES. IT HAS TO PASS ALL THE TEST CASES. I PROVIDED THE CORRECT OUTPUT AS A SCREENSHOT AS A REFERRENCE.
import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.InputMismatchException;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String fileName; do {…
arrow_forward
JAVA PROGRAM
Chapter 4. Homework Assignment (read instructions carefully)
Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits):
Total: nnnnn.nnn
Average: nnnnn.nnn
Class name: FileTotalAndAverage
double_input1.txt double_input2.txt
PLEASE MODIFY THIS CODE, SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL THE TEST CASES, BECAUSE WHEN I UPLOAD IT TO HYPERGRADE IT DOES NOT PASS THE TEST CASES. IT HAS TO PASS ALL THE TEST CASES. I PROVIDED THE CORRECT OUTPUT AS A SCREENSHOT AS A REFERRENCE.
import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.InputMismatchException;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String fileName; do {…
arrow_forward
JAVA PROGRAM
Chapter 4. Homework Assignment (read instructions carefully)
Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits):
Total: nnnnn.nnn
Average: nnnnn.nnn
Class name: FileTotalAndAverage
double_input1.txt double_input2.txt
Test Case 1
Please enter the file name: \ndouble_input1.txtENTERTotal: -5,748.583\nAverage: -57.486\n
Test Case 2
Please enter the file name: \ndouble_input2.txtENTERTotal: 112,546.485\nAverage: 56.273\n
Test Case 3
Please enter the file name: \ndouble_input3.txtENTERFile 'double_input3.txt' does not exist.\nPlease enter the file name again: \ndouble_input1.txtENTERTotal: -5,748.583\nAverage: -57.486\n
arrow_forward
Word Puzzle GameIn this assignment is only for individual. You are going to decode the scrambled word into correct orderin this game. One round of play is as follows:1. Computer reads a text file named words.txt2. Computer randomly picks one word in the file and randomly scrambles characters in the wordmany times to hide the word3. Computer displays the scrambled word to user with indexes and gives the user options to1. Swap two letters in word based on index given2. Solve the puzzle directly3. Quit the game4. If a player chooses to swap letters, the computer reads two indexes and swaps the letters. Thegame resume to step 3 with the newly guessed word. If the resulted word after swapping is thesecret word, the game is over.5. If a user chooses to solve directly, computer prompts the user to enter the guessed word. If it’scorrect, the game is over, otherwise goes to step 3.6. After game is over, display how many times the player has tried to solve the puzzle.The following is sample…
arrow_forward
A file contains a list of telephone number in following form.
Aman 23456
Raj 567854
….. ……….
Assume 10 such entries.
Name contains only one word and name and telephone number are separated by 5 white spaces.
-->Write a program that will create the data file containing the list of telephone number given in above form. Use a class object to store each set of data.
arrow_forward
GRADEBOOK PROJECT
Attached Files: Gradebook.docx (18.278 KB)
Gradebook Practicla Project: use the attached code as an exaple and modify where neccesary to fit your situation
Write a program that uses an array of string objects to hold the five student names, an array of five characters to hold the five students' letter grades, and five
arrays of four doubles to hold each student's set of test scores.
The program should allow the user to enter each student's name and his or her four test scores. It should then calculate and display each student's ayerage test
score and a letter grade based on the average.
Input Validation: Do not accept test scores less than 0 or greater than 100.
Use the following test score grades
Test Score Letter Grade
80-100 -> A
70-79 -> B
60-69 -> C
50-59 -> D
OO
HUAWEI P30 lite
TRIPLE CAMERA
Activate Windows
dolto vers
arrow_forward
Python
arrow_forward
Sample run:
Your 1st vector contains the following elements
January
February
March
April
May
June
July
August
September
October
November
December
Your 2nd vector contains the following elements
May
June
July
arrow_forward
JAVA PROGRAM ASAP
Please CREATE A program ASAP BECAUSE IT IS HOMEWORK ASSIGNMENT so it passes all the test cases. The program must pass the test case when uploaded to Hypergrade.
Chapter 9. PC #14. Word Separator (modified *** Read carefully ***)
Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it line by line. While entering the file name, the program should allow the user to type quit to exit the program. If the file with a given name does not exist, then display a message and allow the user to re-enter the file name.
The file can contain one or more sentences. The program should accept as input each sentence in which all the words are run together, but the first character of each word is uppercase. Convert sentences to strings in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string StopAndSmellTheRoses.” would be converted to “Stop and smell the roses.”…
arrow_forward
JAVA PPROGRAM
Write a program that prompts the user to enter a file name, then opens the file in text mode and reads names. The file contains one name on each line. The program then compares each name with the name that is at the end of the file in a symmetrical position. For example if the file contains 10 names, the name #1 is compared with name #10, name #2 is compared with name #9, and so on. If you find matches you should print the name and the line numbers where the match was found.
While entering the file name, the program should allow the user to type quit to exit the program.
If the file with a given name does not exist, then display a message and allow the user to re-enter the file name.
The file may contain up to 100 names.
You can use an array or ArrayList object of your choosing, however you can only have one array or ArrayList.
Input validation:
a) If the file does not exist, then you should display a message "File 'somefile.txt' is not found." and allow the…
arrow_forward
JAVA PROGRAM
Chapter 4. Homework Assignment (read instructions carefully)
Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits):
Total: nnnnn.nnn
Average: nnnnn.nnn
Class name: FileTotalAndAverage
PLEASE FIX AND MODIFY THIS JAVA SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASSES PLEASES. RIGHT NOW IT SAYS 0 OUT 3 PASSED. THE PICTURES THAT I PROVIDED PROOF THAT WHEN I UPLOAD IT TO HYPERGRADES IT FAILS TEST CASSES. THANK YOU.
import java.io.*;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Please enter the file name: "); while (true) { String fileName = scanner.nextLine(); File file = new File(fileName); if (file.exists() &&…
arrow_forward
JAVA PROGRAM
Chapter 4. Homework Assignment (read instructions carefully)
Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits):
Total: nnnnn.nnn
Average: nnnnn.nnn
Class name: FileTotalAndAverage
PLEASE FIX AND MODIFY THIS JAVA SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASSES PLEASES. RIGHT NOW IT SAYS 0 OUT 3 PASSED. THE PICTURES THAT I PROVIDED PROOF THAT WHEN I UPLOAD IT TO HYPERGRADES IT FAILS TEST CASSES. THANK YOU.
import java.io.*;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Please enter the file name: "); while (true) { String fileName = scanner.nextLine(); File file = new File(fileName); if (file.exists() &&…
arrow_forward
In python please! I am struggling
arrow_forward
Python
arrow_forward
JAVA PPROGRAM ASAP
Hypergrade does not like this program because it says 2 out of 7 passed and take out the extra \n from the program. Please Modify and change this program ASAP BECAUSE IT IS HOMEWORK ASSIGNMENT so it passes all the test cases. The program must pass the test case when uploaded to Hypergrade. Also, for test cases 1-4 it wants only to input Please enter the file name or type QUIT to exit: then input the file and display the Total number of words. For test cases 5 and 7 it wants to only to input Please enter the file name or type QUIT to exit then input input5.txt and then display File: input5.txt does not exist.\n then display Please enter the file name again or type QUIT to exit:\n then type input1.txt to display the total number of words or type quit to exit the program. For test case 6 it wants only to Please enter the file name again or type QUIT to exit:\n then type quit to exit the porgram.
import java.io.File;import java.io.FileNotFoundException;import…
arrow_forward
JAVA PROGRAM
Chapter 4. Homework Assignment (read instructions carefully)
Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits):
Total: nnnnn.nnn
Average: nnnnn.nnn
Class name: FileTotalAndAverage
PLEASE FIX, CHANGE AND MODIFY THIS JAVA PROGRAM SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASSES PLEASES. RIGHT NOW IT SAYS 0 OUT 3 PASSED. THE PICTURES THAT I PROVIDED PROOF THAT WHEN I UPLOAD IT TO HYPERGRADES IT FAILS TEST CASSES. THANK YOU.
import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.InputMismatchException;import java.util.Locale;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String fileName; do {…
arrow_forward
Directions:
Use a file city.txt for answering the questions that follow each scheduling algorithm. This file
has three columns (comma separated): the first column contains the job Id, the second column
indicates the CPU burst, and column three is the arrival time of the corresponding job.
Parallel Programming
It is vaccine season! COVID19 vaccines are out, and everyone is rushing to get one.
Vaccines are available from six different brands and you have been entrusted to write a
program to count the total number of vaccines of each brand administered across 21 cities
in the state. Write a multithreaded program (in the file vaccines.cpp) that counts the number
of vaccines in 21 different files of numbers. Each line in each of the files will contain either
one of the following brand names: v1, v2, v3. Your program must count the number of units
for each vaccine brand administered, across all 21 cities, and display the total number of
units for each brand. The files are named "city1.txt",…
arrow_forward
Directions:
Use a file city.txt for answering the questions that follow each scheduling algorithm. This file has three columns (comma separated): the first column contains the job Id, the second column indicates the CPU burst, and column three is the arrival time of the corresponding job.
Parallel Programming
It is vaccine season! COVID19 vaccines are out, and everyone is rushing to get one. Vaccines are available from six different brands and you have been entrusted to write a program to count the total number of vaccines of each brand administered across 21 cities in the state. Write a multithreaded program (in the file vaccines.cpp) that counts the number of vaccines in 21 different files of numbers. Each line in each of the files will contain either one of the following brand names: v1, v2, v3. Your program must count the number of units for each vaccine brand administered, across all 21 cities, and display the total number of units for each brand. The files are named…
arrow_forward
Can this be done in Java and not C++
arrow_forward
Can you please help me do this program, its for a class called Object Oriented Programming
arrow_forward
Q1:-A file contains a list of telephone number in following form.
Aman 23456
Raj 567854
….. ……….
Assume 10 such entries.
Name contains only one word and name and telephone number are separated by 5 white spaces.
Write a program that will create the data file containing the list of telephone number given in above form. Use a class object to store each set of data.
For Code , use C++ only
NOTE:- Please Solve this question , it's my humble request to you.. please
arrow_forward
Java
arrow_forward
OWrite a program that reads data from a file containing integers that ends with -999.
Output the numbers that are divisible by 7
Output the numbers that are divisible by 11
Output the numbers that are not divisible by 7 or 11.
arrow_forward
java Program
Chapter 4. Homework Assignment (read instructions carefully)
Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits):
Total: nnnnn.nnn
Average: nnnnn.nnn
Class name: FileTotalAndAverage
I do not want a goodbye system out in the program and it has to pass all the test cases.
Test Case 1
Please enter the file name or type QUIT to exit:\ninput1.txtENTERTotal: 11.800\nAverage: 2.950\n
Test Case 2
Please enter the file name or type QUIT to exit:\ninput2.txtENTERTotal: 17.300\nAverage: 3.460\n
Test Case 3
Please enter the file name or type QUIT to exit:\ninput3.txtENTERTotal: 1.124\nAverage: 1.124\n
Test Case 4
Please enter the file name or type QUIT to exit:\ninput4.txtENTERFile input4.txt is empty.\n
Test Case 5
Please enter the file name or type QUIT…
arrow_forward
This question comes from the textbook:Starting out with Visual C# 5th Edition - Chapter 14 Programming Problem 2
Create an application that reads the contents of two text files and uses LINQ extension methods to perform the following:
• It should display a list of all the unique words contained in both files.• It should display a list of the words that appear in both files.• It should display a list of the words that appear in the first file but not the second.• It should display a list of the words that appear in the second file but not the first.• It should display a list of the words that appear in either the first or second file but not both.
Hint: Use set operations to perform these analyses. Also, see Chapter 8 for a discussion of string tokenizing.
arrow_forward
JAVA PPROGRAM ASAP
Please create this program ASAP BECAUSE IT IS MY HOMEWORK ASSIGNMENT so it passes all the test cases. The program must pass the test case when uploaded to Hypergrade.
Chapter 9. PC #10. Word Counter (page 610)
Write a program that asks the user for the name of a file. The program should display the number of words that the file contains.
Input Validation:
Make sure the file exists, before proceeding. Let the user type quit in order to exit the program. If the file is empty, the word count should be 0.
input1.txt
this is a test
input2.txt
thisisatest
input3.txtEmpty
input4txt this this is is a a test test
Test Case 1
Please enter the file name or type QUIT to exit:\ninput1.txtENTERTotal number of words: 4\n
Test Case 2
Please enter the file name or type QUIT to exit:\ninput2.txtENTERTotal number of words: 4\n
Test Case 3
Please enter the file name or type QUIT to exit:\ninput3.txtENTERTotal number of words: 0\n…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Related Questions
- Requested files: InClass02.java, input.txt Maximum number of files: 6 Create a simple java program that reads all the content in a .txt file, the user will enter the filename to be opened. In this case, the file will contain multiple lines of student details with each line containing a single student detail. Your task is to then create a student class that models the firstname, lastname, year of birth and gender of every student. The student class should further be able to assign every student created with a student number using a class variable[format is 2022000X, X is a number such as 1,2..] and be able to calculate the age of each student. Within the driver class add all the students read from file into an ArrayList and then print the first and last student in the list. You are additionally expected to deal with most common exceptions(See samples below) [HINT: DO NOT PROVIDE A PATH BUT RATHER ONLY OPEN THE FILE WITH RELATIVE PATH/FILENAME] Sample run 1: Enter filename:…arrow_forwardTask: Loading data from files This exercise will require you to load some information from files and use it in your program. scene.txt contains a description of a series of shapes and colours to draw. You need to write code to read in the file data and draw the requested shapes in the correct colour. Each line in scene.txt will contain one of the following starting keywords followed by some data: COLOUR followed by 3 values: R, G, B CIRCLE followed by 3 values: X, Y, RADIUS RECT Followed by 4 values: X, Y, W, H LINE Followed by 4 values: X1, Y1, X2, Y2 CIRCLES are defined from the center. RECT's are defined from the top left. All values are space separated, and you can assume all input is correct (no errors). Please solve this program to draw the scene. I can't upload the file scene.txt, so I decide to screenshot a file for you. Subject: Java Programmingarrow_forwardCOMPUTER SCIENCE 130 JAVA PROGRAM Chapter 4. Homework Assignment (read instructions carefully) Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits): Total: nnnnn.nnn Average: nnnnn.nnn Class name: FileTotalAndAverage double_input1.txt double_input2.txt PLEASE FIX AND MODIFY THIS JAVA SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASSES PLEASES. RIGHT NOW IT SAYS 0 OUT 3 PASSED. THE PICTURES THAT I PROVIDED PROOF THAT WHEN I UPLOAD IT TO HYPERGRADES IT FAILS TEST CASSES. THANK YOU. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.InputMismatchException;import java.util.Locale;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String…arrow_forward
- Put the class definition in EV.h and the implementation of the constructors and functions in EV.cpp 1. Define a class called "EV", that represents the information of an electric vehicle. The EV is defined with these attributes: model (string), range(int), unit (string) and year (int). Functions of the EV class must perform the following operations: 1. A default constructor which sets all the numeric instance variables to zero. 2. A constructor with 4 parameters which sets the 4 instance variables to the corresponding values passed. 3. Implement a getter function for each of the 4 instance variables that will return the value of the instance variable. For example, the getX() function for the instance variable model must be called getModel(). 4. Implement a setter function for each instance variable that will assign to the instance variable to the value passed. For example, the setX() function for the instance variable model must be called setModel(). 5. An info function: this function…arrow_forwardJAVA PROGRAM Chapter 4. Homework Assignment (read instructions carefully) Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits): Total: nnnnn.nnn Average: nnnnn.nnn Class name: FileTotalAndAverage double_input1.txt double_input2.txt PLEASE MODIFY THIS CODE, SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL THE TEST CASES, BECAUSE WHEN I UPLOAD IT TO HYPERGRADE IT DOES NOT PASS THE TEST CASES. IT HAS TO PASS ALL THE TEST CASES. I PROVIDED THE CORRECT OUTPUT AS A SCREENSHOT AS A REFERRENCE. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.InputMismatchException;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String fileName; do {…arrow_forwardJAVA PROGRAM Chapter 4. Homework Assignment (read instructions carefully) Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits): Total: nnnnn.nnn Average: nnnnn.nnn Class name: FileTotalAndAverage double_input1.txt double_input2.txt PLEASE MODIFY THIS CODE, SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL THE TEST CASES, BECAUSE WHEN I UPLOAD IT TO HYPERGRADE IT DOES NOT PASS THE TEST CASES. IT HAS TO PASS ALL THE TEST CASES. I PROVIDED THE CORRECT OUTPUT AS A SCREENSHOT AS A REFERRENCE. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.InputMismatchException;import java.util.Scanner;public class FileTotalAndAverage { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String fileName; do {…arrow_forward
- JAVA PROGRAM Chapter 4. Homework Assignment (read instructions carefully) Write a program that asks the user for the name of a file. The program should read all the numbers from the given file and display the total and average of all numbers in the following format (three decimal digits): Total: nnnnn.nnn Average: nnnnn.nnn Class name: FileTotalAndAverage double_input1.txt double_input2.txt Test Case 1 Please enter the file name: \ndouble_input1.txtENTERTotal: -5,748.583\nAverage: -57.486\n Test Case 2 Please enter the file name: \ndouble_input2.txtENTERTotal: 112,546.485\nAverage: 56.273\n Test Case 3 Please enter the file name: \ndouble_input3.txtENTERFile 'double_input3.txt' does not exist.\nPlease enter the file name again: \ndouble_input1.txtENTERTotal: -5,748.583\nAverage: -57.486\narrow_forwardWord Puzzle GameIn this assignment is only for individual. You are going to decode the scrambled word into correct orderin this game. One round of play is as follows:1. Computer reads a text file named words.txt2. Computer randomly picks one word in the file and randomly scrambles characters in the wordmany times to hide the word3. Computer displays the scrambled word to user with indexes and gives the user options to1. Swap two letters in word based on index given2. Solve the puzzle directly3. Quit the game4. If a player chooses to swap letters, the computer reads two indexes and swaps the letters. Thegame resume to step 3 with the newly guessed word. If the resulted word after swapping is thesecret word, the game is over.5. If a user chooses to solve directly, computer prompts the user to enter the guessed word. If it’scorrect, the game is over, otherwise goes to step 3.6. After game is over, display how many times the player has tried to solve the puzzle.The following is sample…arrow_forwardA file contains a list of telephone number in following form. Aman 23456 Raj 567854 ….. ………. Assume 10 such entries. Name contains only one word and name and telephone number are separated by 5 white spaces. -->Write a program that will create the data file containing the list of telephone number given in above form. Use a class object to store each set of data.arrow_forward
- GRADEBOOK PROJECT Attached Files: Gradebook.docx (18.278 KB) Gradebook Practicla Project: use the attached code as an exaple and modify where neccesary to fit your situation Write a program that uses an array of string objects to hold the five student names, an array of five characters to hold the five students' letter grades, and five arrays of four doubles to hold each student's set of test scores. The program should allow the user to enter each student's name and his or her four test scores. It should then calculate and display each student's ayerage test score and a letter grade based on the average. Input Validation: Do not accept test scores less than 0 or greater than 100. Use the following test score grades Test Score Letter Grade 80-100 -> A 70-79 -> B 60-69 -> C 50-59 -> D OO HUAWEI P30 lite TRIPLE CAMERA Activate Windows dolto versarrow_forwardPythonarrow_forwardSample run: Your 1st vector contains the following elements January February March April May June July August September October November December Your 2nd vector contains the following elements May June Julyarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning