subject

See how you can simplify the program that is attached at the bottom- caferanking. java
try to eliminate the switch altogether - you will still have to use an array to compute the total for each ranking (if a rank of "2" was selected 3 times, display 3 for ranking "2", if 5 had selected ranking "1", display 5 for "1",
import java. util. scanner;
public class caferanking{
public static void main(string [] args)
{
scanner input=new scanner(system. in);
int cafescore=0;
int ranking[]=new int[11];
while(cafescore ! = -1)
{
system. out. printf("pls enter your score for the eurocafe: ");
cafescore=input. nextint();
if (cafescore== -1)
{
for(int i=1; i< 11; i++)
system. out. printf("ranking %d received %d times\n",i, ranking[i]);
break;
}
else
{
system. out. println("your score is: "+cafescore);
switch( cafescore )
{
case 1:
//count1++;
ranking[1]++;
break;
case 2:
//count2++;
ranking[2]++;
break;
case 3:
ranking[3]++;
break;
case 4:
ranking[4]++;
break;
case 5:
ranking[5]++;
break;
case 6:
ranking[6]++;
break;
case 7:
ranking[7]++;
break;
case 8:
ranking[8]++;
break;
case 9:
ranking[9]++;
break;
case 10:
ranking[10]++;
break;
default:
system. out. println("incorrect score was entered");
} // end else
} //end switch
}//end loop
}//end main
}//end class

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:30
One of your customers wants you to build a personal server that he can use in his home. one of his concerns is making sure he has at least one backup of their data stored on the server in the event that a disk fails. you have decided to back up his data using raid. since this server is for personal use only, the customer wants to keep costs down. therefore, he would like to keep the number of drives to a minimum. which of the following raid systems would best meet the customer's specifications? a. raid 0 b. raid 1 c. raid 5 d. raid 10
Answers: 3
question
Computers and Technology, 23.06.2019 06:30
You are consulting for a beverage distributor who is interested in determining the benefits it could achieve from implementing new information systems. what will you advise as the first step?
Answers: 1
question
Computers and Technology, 23.06.2019 07:10
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
The basic work area of the computer is it screen that you when you first fire up your computer
Answers: 1
You know the right answer?
See how you can simplify the program that is attached at the bottom- caferanking. java
try to...
Questions
question
Mathematics, 16.01.2021 02:30
question
Mathematics, 16.01.2021 02:30
question
Mathematics, 16.01.2021 02:30
question
Mathematics, 16.01.2021 02:30
question
Social Studies, 16.01.2021 02:30
question
Mathematics, 16.01.2021 02:30
Questions on the website: 13722367