Question

Write a C++ program. Using the while loop or the do – while loop write a...

Write a C++ program. Using the while loop or the do – while loop write a program that does the following:

Calculate the average of a series of homework grades (0 - 100) entered one at a time.

In this case the lowest score will be dropped and the average computed with the remaining grades. For example suppose you enter the following grades: 78, 85, 81, 90, 88, 93 and 97.The average will be computed from the 6 grades 85, 81, 90, 88, 93 and 97. The low score of 78 will be dropped.

Output each grade, the dropped grade and the final average.

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

Program:

#include<iostream>
using namespace std;

int main()
{
int grade,length;
cout<<"How many grades do you want: ";
cin>>length;

int grades[length];

int i=0;
while(i<length)
{
cout<<"Enter Grade "<<(i+1)<<": ";
cin>>grade;
while(1)
{
if(grade>=0 && grade<=100)
{
break;
}
else
{
cout<<"Please Enter Grade (0-100)"<<(i+1)<<": ";
cin>>grade;
}
}
grades[i]=grade;
i++;
}

i=0;
int min=grades[0];

while(i<length)
{
if(min>grades[i])
{
min=grades[i]; //get lowest grade
}
i++;
}


i=0;
int c=0,sum=0;

while(i<length)
{
if(grades[i]!=min)
{
sum=sum+grades[i]; //sum of all grades except lowest grade
c++;
}
i++;
}

double average=(double) sum/c; //calculating the average

cout<<"\n\nGrades with the dropped grade: ";
i=0;
while(i<length)
{
cout<<grades[i]<<" ";
i++;   
}

cout<<"\n\nGrades without the dropped grade: ";
i=0;
while(i<length)
{
if(grades[i]!=min)
{
  
cout<<grades[i]<<" ";
}
i++;   
}
cout<<"\n\nThe dropped grade: "<<min<<endl;
cout<<"\nThe final average: "<<average<<endl;

}

Output:

Add a comment
Know the answer?
Add Answer to:
Write a C++ program. Using the while loop or the do – while loop write a...
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
  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Write a program to calculate students’ average test scores and their grades. You may assume the...

    Write a program to calculate students’ average test scores and their grades. You may assume the following data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Use three...

  • Write a program that uses the keys(), values(), and/or items() dict methods to find statistics about...

    Write a program that uses the keys(), values(), and/or items() dict methods to find statistics about the student grades dictionary. Find the following: Print the name and grade percentage of the student with the highest total of points. Also print the grade as per the below grading scale 90 to 100         A 80 to 89           B 70 to 79           C 60 to 69           D Below 60         F Find the average score of each assignment. Use the following data:...

  • In this assignment, you will write a program in C++ which uses files and nested loops...

    In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...

  • write a program that uses a function to read in the grades for four classes and...

    write a program that uses a function to read in the grades for four classes and then uses a function to calculate the average grade in each of the classes. input the grades for one student. we will name her Beverly. output how Beverly's grade differs from each classe average. Make sure that your output is very clear. Below is your data: English 90 70 85 45 95 95 82 97 99 65 History 63 94 60 76 83 98...

  • Student average array program

    Having a bit of trouble in my c++ class, was wondering if anyone can help.Write a program to calculate students' average test scores and their grades. You may assume the following input data:Johnson 85 83 77 91 76Aniston 80 90 95 93 48Cooper 78 81 11 90 73Gupta 92 83 30 68 87Blair 23 45 96 38 59Clark 60 85 45 39 67Kennedy 77 31 52 74 83Bronson 93 94 89 77 97Sunny 79 85 28 93 82Smith 85 72...

  • Please do in C# with the code available to copy :) Program 4: Design (pseudocode) and...

    Please do in C# with the code available to copy :) Program 4: Design (pseudocode) and implement (source code) a program (name it MinMaxAvg) to determine the highest grade, lowest grade, and the average of all grades in a 4-by-4 two-dimensional arrays of integer grades (representing 4 students’ grades on 4 tests). The program main method populates the array (name it Grades) with random grades between 0 and 100 and then displays the grades as shown below. The main method...

  • Create a C++ program to calculate grades as well as descriptive statistics for a set of...

    Create a C++ program to calculate grades as well as descriptive statistics for a set of test scores. The test scores can be entered via a user prompt or through an external file. For each student, you need to provide a student name (string) and a test score (float). The program will do the followings: Assign a grade (A, B, C, D, or F) based on a student’s test score. Display the grade roster as shown below: Name      Test Score    ...

  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

  • Please help me with this program.You are to write a C++ program that will read in...

    Please help me with this program.You are to write a C++ program that will read in up to 15 students with student information and grades. Your program will compute an average and print out certain reports. Format: The information for each student is on separate lines of input. The first data will be the student�s ID number, next line is the students name, next the students classification, and the last line are the 10 grades where the last grade is...

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