Question

In: Computer Science

Write a C++ program that reads a students name followed by 7 numeric grades from a...

Write a C++ program that reads a students name followed by 7 numeric grades from a file.  Compute the average grade after dropping the  lowest grade.   Assign letter grades via this scale .Please show steps in the comments .

A 90 – 100

B 80  --89

C 70 –79

D 60 -69

F 0  - 59

Input format:

Sam 100 90 87 23 12 67 95

Mary 30 20 90 90 90 90 88

Mark 80 90 80 80 90 87 100

End of file

                                                              REPORT

   Name                                                                                             Grade

      Sam                                                                                                 C

      Mary                                                                                                A

       Mark                                                                                               B

The student with the highest average is   Mary   (99.99)

The student with the lowest average is     Sam    (99.99)

Solutions

Expert Solution

C++ program to find average, total and grade

Steps:

  • Enter the numbers of students detail like to enter
  • Collect the seven subject marks
  • Find total, average and grade

Source code

#include<iostream> 
 #include<conio.h> 
 using namespace std;
 int main ( ) 
 {   
     // define struct and decide the number of subjects
             struct student 
          { 
               int subject1 ; 
               int subject2 ; 
               int subject3 ; 
               int subject4 ;
               int subject5 ;
               int subject6 ;
               int subject7 ;
               
          }; 
        // define number of students markes have to be collected
                int i , n, total; 
                float av ; 
                 
                struct student st[20]; 
                char name[20];
                cout<<" \n Enter the Number of Students marks wish to enter : " ; 
                cin>> n ; 
                for (i =0; i<n; i++) 
                    { 
                        // Collecting the basic details
                        cout<<"Enter the name of Student: ";
                        cin>>name;
                           cout<<"\nEnter the Marks of seven Subjects : " ; 
                           total = 0 ; 
                           cin>> st[i].subject1 >>st[i].subject2>>st[i].subject3>>st[i].subject4>>st[i].subject5>>st[i].subject6>>st[i].subject7; 
                           total = st[i].subject1+st[i].subject2+st[i].subject3+st[i].subject4+st[i].subject5+st[i].subject6+st[i].subject7; 
                           av = (float) total /7 ; 
                           cout<<"Total mark is :"<<total;
                           cout<<"\nAVERAGE Marks of  the Student is : "<< av ; 
                           cout<<"\nYour Grade is :: ";
                         
                          // define the conditions of grade
        if(av>89)
        {
                cout<<"[ A ]\n";
        }
        else if(av>79 && av<=89)
        {
                cout<<"[ B ]\n";
        }
        else if(av>69 && av<=79)
        {
                cout<<"[ C ]\n";
        }
        else if(av>59 && av<=69)
        {
                cout<<"[ D ]\n";
        }
        else
        {
            cout<<"[ F ]\n";
        }
        
                     } 
                           
                           return 0;
 }

The output:


Related Solutions

using c++. ALWAYS GRADE MY ANSWERS Write a program that reads students’ names followed by their...
using c++. ALWAYS GRADE MY ANSWERS Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType, which has four components: studentFName and studentLName of type string, testScore of type...
Write a program that reads students’ names followed by their test scores. The program should output...
Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType, which has four components: studentFName and studentLName of type string, testScore of type int (testScore is between 0 and...
In java Q2. Write a program that reads grades of type double of eight students that...
In java Q2. Write a program that reads grades of type double of eight students that the user provides. The grades lie between 0 and 10. These grades should be written to a binary file and read from it. The program outputs the highest and lowest grades achieved by students on the screen. The file contains nothing but numbers of type double written to the file with writeDouble.
C++ Write a program that prompts for a file name and then reads the file to...
C++ Write a program that prompts for a file name and then reads the file to check for balanced curly braces, {; parentheses, (); and square brackets, []. Use a stack to store the most recent unmatched left symbol. The program should ignore any character that is not a parenthesis, curly brace, or square bracket. Note that proper nesting is required. For instance, [a(b]c) is invalid. Display the line number the error occurred on. These are a few of the...
Write a C++ program that reads a file consisting of students’ test scores in the range...
Write a C++ program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176,...
Write a program that reads three values from the keyboard representing, respectively, an investors name, an...
Write a program that reads three values from the keyboard representing, respectively, an investors name, an investment amount, and an interest rate (you will expect the user to enter a number such as .065 for the interest rate, representing a 6.5% interest rate) . Your program should calculate and output (in currency notation) the future value of the investment in 10, 2 20 an 30 years using the following formula:   Future value =investment(1+interest rate)year Example of a test run: Enter...
Exercise 7: Name that Shape Write a program that determines the name of a shape from...
Exercise 7: Name that Shape Write a program that determines the name of a shape from its number of sides. Read the number of sides from the user and then report the appropriate name as part of a meaningful message. Your program should support shapes with anywhere from 3 up to (and including) 10 sides. If a number of sides outside of this range is entered then your program should display an appropriate error message. language use : python
Write a Python program that asks the user to enter a student's name and 8 numeric...
Write a Python program that asks the user to enter a student's name and 8 numeric tests scores (out of 100 for each test). The name will be a local variable. The program should display a letter grade for each score, and the average test score, along with the student's name. Write the following functions in the program: calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student determine_grade -...
Write a program in c that reads the content from the file and stores each line...
Write a program in c that reads the content from the file and stores each line in an int array in heap(using dynamic memory allocation). For example, let the file has elements following (we do not know the size of files, it could be above 100,000 and contents of the file and make sure to convert file elements to int): 10067 26789 6789 3467
(C++) Write a program that reads a list of integers from the keyboard and print out...
(C++) Write a program that reads a list of integers from the keyboard and print out the smallest number entered. For example, if user enters 0 3 -2 5 8 1, it should print out -2. The reading stops when 999 is entered.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT