Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java write a program that prompts users to enter a score ( 0 to 1 0 0 ) at a time for five scores,

in java write a program that prompts users to enter a score(0 to 100) at a time for five scores,
and then, write the scores into a file.
Sample run: User-entered values are shown in red.
Enter score 1: 90
Enter score 2: 82
Enter score 3: 39
Enter score 4: 89
Enter score 5: 99
A new file will be created for the report.
Enter the new file name(For example, MyReport.txt.):
YourReport.txt
Report written into a file: YourReport.txt
The following shows how the scores are stored in the output file: YourReport.txt
You must use the required Java classes and loop statements specified in the following instructions.
Start your eclipse, go to the same workspace as your lab 05.
Create a new Java Project using File/New/Java Project in the menu bar. Enter a project name. If
package explorer is invisible, show it using Window/Show View/Package Explorer.
Add a package to folder src. Right click src, choose New/Package in the menu bar. Enter a package
name.
You must use an int[] to store the scores.
Next, translate the input module of your algorithm. This is a block for which comments are
needed. You may turn the sentences in the input module of your algorithm into comments
here. If needed, break this block into subblocks and add more comments. Write Java
statements according to the comments.
You must write one prompt statement in a for loop that executes five times. When
executed, the loop prompts user to enter the next score and store it into the next location of
the score array. The prompt should end with a serial number .
Enter score 1: 90
Enter score 2: 82
Enter score 3: 39
Enter score 4: 89
Enter score 5: 99
A new file will be created for the report.
Enter the new file name (For example, MyReport.txt.):
YourReport.txt
Report written into a file: YourReport.txt
You must have the required prompt for the input. You must use length (instead of 5), the
instance variable of arrays, to determine the terminating index in the for loop.
To read a user-entered value, you will need to create a Scanner object using new operator
and a Scanner constructor and save it into a Scanner variable - an object reference.
To read a user-entered value such as an int, use the Scanner object reference to invoke the
following instance method in Scanner class.
public int nextInt()
Scans the next token of the input as an int.
In addition to the five scores, the new file name is entered as well.
Next, translate the process module of your algorithm. This is a block for which comments
are needed. You may turn the sentences in the process module of your algorithm into
comments here. If needed, break this block into subblocks and add more comments. Write
Java statements according to the comments.
For this lab, there is not much process since the inputs are written to an output file.
Lastly, translate the output module of your algorithm. This is a block for which comments
are needed. You may turn the sentences in the output module of your algorithm into
comments here. If needed, break this block into subblocks and add more comments. Write
Java statements according to the comments. The outputs must be displayed in a format
shown in the sample runs.
You must create a File object using the user-entered file name, pass the file object to the
PrintWriter constructor. The file must be stored in the root/Java project folder, the default
folder. Use the PrintWriter object reference to call println method to write the scores stored
int the array to the output file.
You can only use println once in a for loop that executes five times. When executed, the
loop combines Score # with the score in the array in the required format, and then, writes
the combined value into the output file.
Score 1: 90
Score 2: 82
Score 3: 39
Score 4: 89
Score

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

In what ways do lenders and investors lend legitimacy to a firm?

Answered: 1 week ago

Question

5. Discuss the role of the Web in career management.

Answered: 1 week ago

Question

4. Design a career management system.

Answered: 1 week ago

Question

4. Evaluation is ongoing and used to improve the system.

Answered: 1 week ago