Java Program Using Eclipse Project
Description
Create a Java Program do to the following. These tasks can all be done in the main() method. For Tasks 1-3, use a variable name of your choosing.
- Create a Scanner object for keyboard input.
- Create a File Object using the file name “MyGrades.txt”.
- Create a PrintWriter Object using the FileObject created from Step 2.
- Allow PrintWrite to throw a FileNotFoundException as part of the main() method header.
- Create a double variable named myGrade.
- Create a do while loop with the following tasks in the loop body.
- Prompt for a grade and store the result in myGrade
- If myGrade is not equal to -99 – Use PrintWriter to “println” myGrade to disk.
- If myGrade == -99 – The loop should exit.
- Close the PrintWriter Object.
- Create a Scanner Object using the File Object created in Step 2.
- Create the double variables totalScore and average. Initialize these variables to zero.
- Create the int variable counter and initialize it to zero.
- Create a while loop to read each double data item found in the Scanner Object
- Increment the counter variable for each loop iteration
- Read the file’s double variable into myGrade (As defined in Step 4)
- Add myGrade to the totalScore variable.
- Calculate the average as totalScore / counter
- Display the counter, totalScore and Average.
- Use printf and format specifiers to display the double variables in #####.## format.
- Close the File Scanner object from Step 7.
- Close the Scanner object from Step 1.
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."