Question

Write a short C++ program that prompts the user for a series of ten scores in...

Write a short C++ program that prompts the user for a series of ten scores in the range of  0-10 and adds them into a total. Check to make sure the numbers that are entered are actually in the proper 0-10 range.

If a 10 is entered then add the ten to the total then double the total to that point.   If a 5 is entered then add five to the total then divide the total by 2 (throwing away any remainders) to that point.  

So if the total was 7 and a 10 was enter then the new total would be (7+10)*2 = 34.. If then a 5 was entered after that then the new total would be (34+5)/2 = 19.

At the end of the loop, divide the final total by 10 to produce a type of average.

If the overall total itself is above 100 at the end then also print out "Test Warrior".     '

If the overall average is above 6 at the end but the score is not above 100 then print out "Good Job".  

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
using namespace std;
int main(){
/**
* Integer variables are declared below as per requirement
* n : It will store the values entered by user
* counter : It will store the count of valid values entered by user
* sum : It will store the summation of the values entered
*/
int n, counter=0,sum=0;


/**
* Following while loop runs until all the 10 values are not scanned
*/
while(true){
/**
* Check if counter is 10 or no.
*/
if(counter==10){
break;
}

/**
* Prompting user to enter the value in range 0-10
*/
cout<<"Enter any value in range 0-10: ";
cin>>n;

/**
* Check if n is in range or no
*/
if(n>=0 && n<=10){
/**
* Increment the counter by 1
*/
counter++;
if(n==10){
sum = (sum + 10)*2;
}else if(n==5){
sum = (sum + 5)/2;
}
}else{
cout<<"Invalid Value!"<<endl;
}
}/*While loop ends here*/

/**
* Calculating the average
*/
int average = sum/10;

if(sum>100){
cout<<"Test Warrior"<<endl;
}
if(average>6 && sum<=100){
cout<<"Good Job"<<endl;
}

return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write a short C++ program that prompts the user for a series of ten scores in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The Assignment Design a Visual Logic flowchart for a program that prompts the user to enter...

    The Assignment Design a Visual Logic flowchart for a program that prompts the user to enter ten numbers one at a time. Use Console I/O (not the GUI interface). After the user has entered all ten number the program will then print out the total of those ten number and quit. Here is one example of what the program might look like when run: Please enter a number: 5 Please enter a number: 10 Please enter a number: 2 Please...

  • 5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters...

    5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below. ​ 1 largest = None 2 smallest = None 3 while True: 4...

  • Write a program that prompts the user to enter a number within the range of 1...

    Write a program that prompts the user to enter a number within the range of 1 to 10 inclusive. The program then generates a random number using the random class: If the users guess is out of range use a validation loop (DO) to repeat the prompt for a valid number, If the users guess matches the random number tell them they win! If the users guess does not match the random number tell them they are wrong. Use a...

  • Write a program named ClassifyScores that classifies a series of scores entered by the user into...

    Write a program named ClassifyScores that classifies a series of scores entered by the user into ranges (0-9, 10-19, and so forth). The scores will be numbers between 0 and 100. Design and implement a program to prompt the user to enter each score separately. If the score is within the correct range, then increment the appropriate range If the score entered is greater than 100, display an error message, ignore the incorrect score, and prompt for the user to...

  • write a c program for the above Write a program which prompts the user to enter...

    write a c program for the above Write a program which prompts the user to enter three integers (data type int) and then calculates the arithmetic average as a decimal number and prints the value with two decimal digits. If you have time also calculate and print the harmonic mean of the same numbers according to the following formula: 3. PT harmonic _mean-1 1 22x (Test with integer values of 4, 7, and 8. You may submit one program per...

  • Python Code Write a program using functions and mainline logic which prompts the user to enter...

    Python Code Write a program using functions and mainline logic which prompts the user to enter a number. The number must be at least 5 and at most 20. (In other words, between 5 and 20, inclusive.) The program then generates that number of random integers and stores them in a list. The random integers should range from 0 to 100. (You can use a wider range if you want, but the lower end of the range must be at...

  • Write a program that allows the user to enter a series of exam scores. The number...

    Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop...

  • Question: - write a C++ program that asks user to enter students' quiz scores, calculate the...

    Question: - write a C++ program that asks user to enter students' quiz scores, calculate the total score for each students and average for all. Note: - number of students: 1 through 5. That is, at least one student and up to 5. - number of quizes: 8 through 10. That is, at least 8 quizes and up to 10. - quiz score range: 0 through 100. - when entering quiz scores, if user enters -1, that means the user...

  • Write a program called CountCoins.java that prompts the user for the input file name (you can...

    Write a program called CountCoins.java that prompts the user for the input file name (you can copy the getInputScanner() method given in the ProcessFile assignment) then reads the file. The file contains a series of pairs of tokens, where each pair begins with an integer and is followed by the type of coin, which will be “pennies” (1 cent each), “nickels” (5 cents each), “dimes” (10 cents each), or “quarters” (25 cents each), case-insensitively. Add up the cash values of...

  • Q1 (2 pts) Shopping list Write a program that prompts a user for items on their...

    Q1 (2 pts) Shopping list Write a program that prompts a user for items on their shopping list and keeps prompting the user until they enter "Done" (make sure your program can stop even if the user enters "Done" with different cases, like "done"), then prints out the items in the list, line by line, and prints the total number of items on the shopping list. Output (after collecting items in the while loop) should look something like this: Apple...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT