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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:30, moomoo2233
What’s the process of observing someone actually working in a career that interests you?
Answers: 1
image
Computers and Technology, 22.06.2019 02:20, eagles2286
The reset circuit used on the four 3-bit counters analyzed in this activity reset the counts to zero (000). it makes sense for the up-counters to start at zero (000), but the down-counters should start at seven (111). what would you need to change so that the 3-bit binary down counter with j/k flip-flops you just created would reset to seven (111)?
Answers: 1
image
Computers and Technology, 22.06.2019 07:50, OnlyaBurden
In this lab, you complete a prewritten c++ program for a carpenter who creates personalized house signs. the program is supposed to compute the price of any sign a customer orders, based on the following facts: the charge for all signs is a minimum of $35.00. the first five letters or numbers are included in the minimum charge; there is a $4 charge for each additional character. if the sign is made of oak, add $20.00. no charge is added for pine. black or white characters are included in the minimum charge; there is an additional $15 charge for gold-leaf lettering. instructions ensure the file named housesign. cppis open in the code editor. you need to declare variables for the following, and initialize them where specified: a variable for the cost of the sign initialized to 0.00 (charge). a variable for the number of characters initialized to 8 (numchars). a variable for the color of the characters initialized to "gold" (color). a variable for the wood type initialized to "oak" (woodtype). write the rest of the program using assignment statements and ifstatements as appropriate. the output statements are written for you. execute the program by clicking the run button. your output should be: the charge for this sign is $82. this is the code, // housesign. cpp - this program calculates prices for custom made signs. #include #include using namespace std; int main() { // this is the work done in the housekeeping() function // declare and initialize variables here // charge for this sign // color of characters in sign // number of characters in sign // type of wood // this is the work done in the detailloop() function // write assignment and if statements here // this is the work done in the endofjob() function // output charge for this sign cout < < "the charge for this sign is $" < < charge < < endl; return(0); }
Answers: 1
image
Computers and Technology, 22.06.2019 10:30, JeroMii
Think about a recent customer service experience - either positive or negative. write a brief summary of that experience. now think about those four characteristics we look for in customer service representatives. how did the representative in your example stack up? write down your answer and give specific examples.
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 in other subjects:

Konu
Mathematics, 21.01.2021 01:00
Konu
Mathematics, 21.01.2021 01:00
Konu
Mathematics, 21.01.2021 01:00
Konu
History, 21.01.2021 01:00