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, 21.06.2019 15:30
Some of the items below indicate the steps required to move a slide to a different location in a presentation. select those steps and indicate the order in which they should be performed to move the slide. (for example, if an item describes what you do first, select 1.) included in the list are items that are not part of the process. for these items, select n/a, an abbreviation for not applicable. 1 — first 2 — second 3 — third 4 — fourth 5 — fifth 6 — sixth n/a — not applicable drag the slide to the desired place. enter the slide position desired. hold the mouse button down. select move from the tools menu. select the slide. switch to the notes view.
Answers: 3
question
Computers and Technology, 22.06.2019 17:30
The forerunner to cell phones, pdas, and smartphones was
Answers: 1
question
Computers and Technology, 22.06.2019 19:00
Stacy works as blank. the most important soft skill she needs for this role is blank.
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
For her science class, elaine is creating a presentation on weather in the united states. she wants to make the presentation beautiful and interesting by drawing simple cloud or wave shapes. which is the best way for elaine to draw these shapes?
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, 01.03.2021 04:50
question
Mathematics, 01.03.2021 04:50
question
Mathematics, 01.03.2021 04:50
question
Mathematics, 01.03.2021 04:50
question
Mathematics, 01.03.2021 04:50
question
French, 01.03.2021 04:50
question
History, 01.03.2021 04:50
Questions on the website: 13722362