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.

  1. Create a Scanner object for keyboard input.
  2. Create a File Object using the file name “MyGrades.txt”.
  3. Create a PrintWriter Object using the FileObject created from Step 2.
    1. Allow PrintWrite to throw a FileNotFoundException as part of the main() method header.
  4. Create a double variable named myGrade.
  5. Create a do while loop with the following tasks in the loop body.
    1. Prompt for a grade and store the result in myGrade
    2. If myGrade is not equal to -99 – Use PrintWriter to “println” myGrade to disk.
    3. If myGrade == -99 – The loop should exit.
  6. Close the PrintWriter Object.
  7. Create a Scanner Object using the File Object created in Step 2.
  8. Create the double variables totalScore and average. Initialize these variables to zero.
  9. Create the int variable counter and initialize it to zero.
  10. Create a while loop to read each double data item found in the Scanner Object
    1. Increment the counter variable for each loop iteration
    2. Read the file’s double variable into myGrade (As defined in Step 4)
    3. Add myGrade to the totalScore variable.
  11. Calculate the average as totalScore / counter
  12. Display the counter, totalScore and Average.
    1. Use printf and format specifiers to display the double variables in #####.## format.
  13. Close the File Scanner object from Step 7.
  14. Close the Scanner object from Step 1.

Get your college paper done by experts

Do my question How much will it cost?

Place an order in 3 easy steps. Takes less than 5 mins.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *