Question

In: Computer Science

Write a program to print the number of class assignments you have done so far, the...

Write a program to print the number of class assignments you have done so far, the total grades, and average grade. Prompt a 0 input to end the program.

Java

Using while statements in the lecture this was provided. Wording confused me, Total grade is sum of all grades.

Solutions

Expert Solution

/*******************************************************/
#include <iostream>

using namespace std;

int main()
{

// Declaring variables
int grade, tot = 0, count = 0;
double avg = 0.0;

/* This while loop continues to execute
* until the user enter grade as 0
*/
while (true)
{

/* This while loop continues to execute
* until the user chooses valid grade
*/
while (true)
{
cout << "Enter grade (0 to exit):";
cin >> grade;
if (grade == 0)
{
break;
}
else if (grade < 0 || grade > 100)
{
cout << "** Invalid.Must be between 1 - 100 **" << endl;
}
else
{
break;
}
}

if (grade == 0)
{
break;
}
else
{
// Calculating the sum of all grades
tot += grade;
// Counting no of grades
count++;
}
}

// Calculating the average
avg = ((double)tot / count);

// displaying the output
cout << "Sum of all grades :" << tot << endl;
cout << "Average of all grades :" << avg << endl;


return 0;
}

/*******************************************************/

/*******************************************************/

Output:

/*******************************************************/


Related Solutions

Considering the calculations you have done so far, you need to attend to a number of...
Considering the calculations you have done so far, you need to attend to a number of import and export transactions for goods that companies in the United States expressed interest in. The first transaction is for the import of good quality wines from Australia, since a retail liquor trading chain customer in the United States, for who you have been doing imports over the past five years has a very large order this time. The producer in Australia informed you...
Considering the calculations you have done so far, you need to attend to a number of...
Considering the calculations you have done so far, you need to attend to a number of import transactions for goods that companies in the United States expressed interest in. The first transaction is for the import of good quality wines from France, since a retail liquor trading chain customer in the United States, for who you have been doing imports over the past five years has a very large order this time. The producer in France informed you that the...
Considering the calculations you have done so far, you need to attend to a number of...
Considering the calculations you have done so far, you need to attend to a number of import transactions for goods that companies in the United States expressed interest in. The first transaction is for the import of good quality wines from France, since a retail liquor trading chain customer in the United States, for who you have been doing imports over the past five years has a very large order this time. The producer in France informed you that the...
Considering the calculations you have done so far, you need to attend to a number of...
Considering the calculations you have done so far, you need to attend to a number of import transactions for goods that companies in the United States expressed interest in. The first transaction is for the import of good quality wines from France, since a retail liquor trading chain customer in the United States, for who you have been doing imports over the past five years has a very large order this time. The producer in France informed you that the...
Considering the calculations you have done so far, you need to attend to a number of...
Considering the calculations you have done so far, you need to attend to a number of import and export transactions for goods that companies in the United States expressed interest in. The first transaction is for the import of good quality wines from Australia, since a retail liquor trading chain customer in the United States, for who you have been doing imports over the past five years has a very large order this time. The producer in Australia informed you...
This is for AT&T: The analysis you have done so far might lead you to expect...
This is for AT&T: The analysis you have done so far might lead you to expect your company to operate with a particular kind of structure. What kind? To what extent does your organizations structure seem to fit with the characteristics of the organization’s technology? For example. Is the structure organic or mechanistic?
a. Panther Marine mangement is very impressed with the work you have done so far filling...
a. Panther Marine mangement is very impressed with the work you have done so far filling in for the regular accountant. They have reached there fiscal year end and now need your help creating the financial statements for the fiscal year ended June 30, 2017. b. Check figures are NOT available for part II. Financial statements have the following built-in check figures: 1. Balance sheet total assets must equal total liabilities and stockholder's equity 2. Statement of cash flows net...
Using the information you have learned so far in this class, state what you think will...
Using the information you have learned so far in this class, state what you think will cause market fluctuations over the next few years as the economy struggles to recover.
This is what I have so far. The out print I am looking for is Date...
This is what I have so far. The out print I am looking for is Date is 7/22/2020 New month: 9 New day: 5 New Year: 2020 Date is 9/5/2020 #include    class Date {    public:        Date::Date(int dateMonth, int dateDay, int dateYear)        month{dateMonth}, day{dateDay}, int dateYear}{}               //void displayDate();         //set month        void Date::setMonth(std::int dateMonth){            month = dateMonth;        }        //retrieve month   ...
You have to write a program that will read an array from a file and print...
You have to write a program that will read an array from a file and print if the numbers in the file are right truncatable primes. A right truncatable prime is a prime number, where if you truncate any numbers from the right, the resulting number is still prime. For example, 3797 is a truncatable prime number number because 3797, 379, 37, and 3 are all primes. Input-Output format: Your program will take the file name as input. The first...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT