Computers and Technology
Computers and Technology, 06.12.2019 02:31, mandy9386

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

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:00, savannahckatz
Business professionals of america, and future business leaders of america โ€“ phi beta lambda are both open to business students at which levels? check all that apply. elementary school middle school high school college
Answers: 1
image
Computers and Technology, 23.06.2019 11:30, talyku7131
Me dangers of social media and the internetexplain what each means: 1) social media and phones have become an addiction.2) outside people have access to you all the time.3) cyberstalking4) cyberbullying5) catphishing6) viruses7) identity theft8) credit card fraud9) hacking10) money schemes
Answers: 1
image
Computers and Technology, 23.06.2019 18:20, Blossom824
What is wi-fi infrastructure? a metropolitan area network that uses radio signals to transmit and receive data a communications technology aimed at providing high-speed wireless data over metropolitan area networks a means by which portable devices can connect wirelessly to a local area network, using access points that send and receive data via radio waves includes the inner workings of a wi-fi service or utility, including the signal transmitters, towers, or poles and additional equipment required to send out a wi-fi signal
Answers: 2
image
Computers and Technology, 24.06.2019 07:00, jordaaan101
Guys do you know sh27 cause he hacked me : ( pidgegunderson my old user
Answers: 2
Do you know the correct answer?
See how you can simplify the program that is attached at the bottom- caferanking. java
try to...

Questions in other subjects:

Konu
Mathematics, 08.02.2021 18:50
Konu
Mathematics, 08.02.2021 18:50