Question

In: Computer Science

We want to count how many passing grades are entered. We don’t know how many grades...

We want to count how many passing grades are entered. We don’t know how many grades there will be. Use a sentinel controlled while loop that will ask the user to enter student grades until a value of -1 is entered. Use a counter variable to count all the grades that are passing grades, where 70 is the minimum passing grade. If there are any grades that are out of the range 0 – 100, present an error message to the user, and do not count that grade as passing. We also would like to see what percentage of the valid grades are passing.

Solutions

Expert Solution

Explanation:

Here is the code which keeps asking the user for the grades until the user enters a -1 for the grade.

All the valid grades are considered only, and the passing grades are counted and at last, the count is printed along with the percentage of passing grades among the valid grades entered.

Code;


#include <iostream>

using namespace std;

int main()
{
int grade;
  
cout<<"Enter grade: ";
cin>>grade;
  
int pass = 0;
int count = 0;
  
while(grade!=-1)
{
if(grade<0 || grade>100)
cout<<"Invalid Grade. Range should be 1-100"<<endl;
else
{
count++;
  
if(grade>=70)
pass++;
}
  
cout<<"Enter grade: ";
cin>>grade;
}

cout<<"Total number of passing grades entered: "<<pass<<endl;
cout<<"Percentage of passing grades entered: "<<(float)(pass*100)/(float)count;
return 0;
}

Output:

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!

PLEASE COMMENT IF YOU NEED ANY HELP!


Related Solutions

C Programming use notes Start by asking the user how many grades are to be entered....
C Programming use notes Start by asking the user how many grades are to be entered. Then ask for each one of theses grades. Calculate the average grade and the number of failing grades (grade less than 70). Display on the screen the average grade and the number of failing grades
Write a Java program that will first ask the user how many grades they want to...
Write a Java program that will first ask the user how many grades they want to enter. Then use a do…while loop to populate an array of that size with grades entered by the user. Then sort the array. In a for loop read through that array, display the grades and total the grades. After the loop, calculate the average of those grades and display that average. Specifications Prompt the user for the number of grades they would like to...
Write the following Python script: Problem Statement We want to know how many different people have...
Write the following Python script: Problem Statement We want to know how many different people have eaten at a restaurant this past week. The parameter meals has strings in the format "name:restaurant" for a period of time. Sometimes a person eats at the same restaurant often. Return the number of different people who have eaten at the eating establishment specified by parameter restaurant. For example, "John Doe:Moes" shows that John Doe ate one meal at Moes. Write function howMany that...
If you want to know if there is any difference at all in how many people...
If you want to know if there is any difference at all in how many people prefer any of five different salad dressings, you would do what kind of test? Chi square goodness of fit Chi square test of independence Independent sample (simple) ANOVA Repeated measures(matched sample)ANOVA Factorial ANOVA
I want to know if a prep course increases passing rates for the CPA exam. I...
I want to know if a prep course increases passing rates for the CPA exam. I will compare passing rates of people that had a prep course and those that didn't. Should I run this as a between participants deign or repeated measures? Describe the advantages and disadvantages of your choice.
1. We have two potential designs for the homepage of our website, but we don’t know...
1. We have two potential designs for the homepage of our website, but we don’t know which one to use. The CEO likes one, and the CRO (Chief Revenue Office) likes another. Half the company likes one, and the other half of the company likes the other. Which one should we use? 2. Let's say you have an Excel spreadsheet with 10,000 leads from a few months back -- long enough that those leads' sales cycle has passed. The file...
How many spermatogonia entered meiosis?
How many spermatogonia entered meiosis?
We want to know whether or not there is a difference in the proportion of A’s...
We want to know whether or not there is a difference in the proportion of A’s in math class received by students who participated in a tutoring program and those who did not participate. There are 40 kids who did the tutoring program and 14 of them got A’s. There are 52 who did not do the tutoring program and 12 of them also got A’s. Apply 2-sided test at 4% SL. What more is needed? This is what we...
What does Lean Manufacturing try to accomplish? How? Why? Where? When? What message don’t we want...
What does Lean Manufacturing try to accomplish? How? Why? Where? When? What message don’t we want Lean to represent, Why? Why is visual management so important? Provide 3 examples from your personal experiences and what would occur if they did not exist?
Count how many food boxes "Classic - 3 meals per week for 2 people" we sold...
Count how many food boxes "Classic - 3 meals per week for 2 people" we sold via marketing channel "TV / Radio Advertising" (Solve with 1 formula and show the formula you used) Please Tell me the steps on how this would be solved using Excel. Note that this is not the full excel data but just a small sample. date_sign_up customer_id product_name marketing_channel City 4/17/2015 13:11 71041 Classic - 3 meals per week for 2 people Search Engine Marketing...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT