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 16:00
Ihave 25$ on an itunes card and i need to buy spotify premium, i have no other payment method.
Answers: 2
question
Computers and Technology, 23.06.2019 10:20
Suppose there is a relation r(a, b, c) with a b+-tree index with search keys (a, b).1. what is the worst-case cost of finding records satisfying 10 < a < 50 using this index, in terms of the number of records n1, retrieved and the height h of the tree? 2. what is the worst-case cost of finding records satisfying 10 < a < 50 and 5 < b < 10 using this index, in terms of the number of records n2 that satisfy this selection, as well as n1 and h defined above? 3. under what conditions on n1 and n2, would the index be an efficient way of finding records satisfying the condition from part (2)?
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
Which of the following is not an enhancement to the standard wiki to make it more attractive for corporations? encryptionwork spacespermission toolspredictive text
Answers: 2
question
Computers and Technology, 23.06.2019 22:00
Take a critical look at three gui applications you have usedโ€”for example, a spreadsheet, a word-processing program, and a game. describe how well each conforms to the gui design guidelines listed in this chapter.
Answers: 3
You know the right answer?
See how you can simplify the program that is attached at the bottom- caferanking. java
try to...
Questions
question
Geography, 12.03.2021 22:50
question
English, 12.03.2021 22:50
question
Spanish, 12.03.2021 22:50
question
Mathematics, 12.03.2021 22:50
Questions on the website: 13722367