I need help with a java program?

How to change video games to apply scanner instead of JOptionPane

final int ARRAYSIZE = 5 VARIOUS;
int testScores = brand-new intARRAYSIZE;
Chain score = “”; // Name of the test report file
twice totalScores =0; //Initialize the particular variable totalScores for you to 0
//Initialize index chart i for you to 0
int when i = 0;
//Input quality scores and also accumulate them
while(i <ARRAYSIZE)
//Input a new testscore
credit score = JOptionPane.showInputDialog(“Enter a test score #” + (i+ 1));
testScoresi = Integer.parseInt(score);
//Accumulate quality scores
totalScores = totalScores +testScoresi;
//Increase index chart i by means of one
i=i+1;;

//Calculate the particular average
twice average;
typical =totalScores/100.0;
//Display the particular average
Program.out.println(“Average:” + average);
//Determine the best score
int lowestScore = testScores0;
for (i = A SINGLE; i < ARRAYSIZE; i++)
when (testScoresi < lowestScore)
lowestScore = testScoresi;
Program.out.println(“Lowest Credit score:” +lowestScore);
//Determine very high score.If you understand the particular code on how to determine the best test credit score above, you should be able to complet the particular code
//to determine very high score
int highestScore =testScores0;
for(i=1; i<ARRAYSIZE; i++)

if(testScoresi>highestScore)
highestScore=testScoresi;

Program.out.println(“Highest Credit score:” + highestScore);

Program.exit(0);

// Finish of main() procedure.

// Finish class.

Thank you

Are people sure you would like to use scanner Because GUI associated with Java would not support Protection.Scanner must be used to get access to input only from your Console.

Anyway, Here’s how i do it

final int ARRAYSIZE = 5 VARIOUS;
int testScores = brand-new intARRAYSIZE;
Chain score = “”; // Name of the test report file
twice totalScores =0; //Initialize the particular variable totalScores for you to 0
//Initialize index chart i for you to 0
int when i = 0;
//Input quality scores and also accumulate them
Reader in = brand-new Scanner(System.in);
while(i <ARRAYSIZE)
//Input a new testscore
credit score = throughout.nextInt();
testScoresi =Integer.parseInt(score);
//Accumulate quality scores
totalScores = totalScores +testScoresi;
//Increase index chart i by means of one
i=i+1;;

//Calculate the particular average
twice average;
typical =totalScores/100.0;
//Display the particular average
Program.out.println(“Average:” + average);
//Determine the best score
int lowestScore = testScores0;
for (i = A SINGLE; i < ARRAYSIZE; i++)
when (testScoresi < lowestScore)
lowestScore = testScoresi;
Program.out.println(“Lowest Credit score:” +lowestScore);
//Determine very high score.If you understand the particular code on how to determine the best test credit score above, you should be able to complet the particular code
//to determine very high score
int highestScore =testScores0;
for(i=1; i<ARRAYSIZE; i++)

if(testScoresi>highestScore)
highestScore=testScoresi;

Program.out.println(“Highest Credit score:” + highestScore);

Program.exit(0);

// Finish of main() procedure.

// Finish class.

Right so that you can create that while loop produce a scanner of which takes Program.in as being a parameter.In this way:
Reader myScanner = brand-new Scanner(System.in);

Then to obtain a score only call that scanner, including so:
Program.out.println(“Enter your score:”);
credit score = myScanner.nextInt();

Leave a Reply