Question

In: Computer Science

Topics Loops while Statement Description Write a program that computes the letter grades of students in...

Topics Loops while Statement Description Write a program that computes the letter grades of students in a class from knowing their scores in a test. A student test score varies from 0 to 100. For a student, the program first asks the student’s name and the student’s test score. Then, it displays the student name, the test score and the letter grade. It repeats this process for each student. The user indicates the end of student data by entering two consecutive forward slashes ( // ) when asked for the student name. At the end, the program displays a summary report including the following: · The total number of students. · The total number of students receiving grade “A”. · The total number of students receiving grade “B”. · The total number of students receiving grade “C”. · The total number of students receiving grade “D”. · The total number of students receiving grade “F”. The program calculates a student's the letter grade from the student's test score as follows: A is 90 to 100 points B is 80 to 89 points C is 70 to 79 points D is 60 to 69 points F is 0 to 59 points. Requirements Do this exercise using a While statement and an If/Else If statement. Testing For turning in the assignment, perform the test run below using the input data shown Test Run (User input is shown in bold). Enter Student Name Alan Enter Student Score 75 Alan 75 C Enter Student Name Bob Enter Student Score: 90 Bob 90 A Enter Student Name Cathy Enter Student Score 80 Cathy 80 B Enter Student Name Dave Enter Student Score: 55 Dave 55 F Enter Student Name Eve Enter Student Score 85 Eve 85 B Enter Student Name // Summary Report Total Students count 5 A student count 1 B student count: 2 C student count 1 D student 0 F students 1 Sample Code string name; double score; //Initias setup cout << "Enter student name" << endl; cin >> name; //Test while (name != "//") { cout << "Enter student score" << endl; cin >> score; //more code here //Update setup out << "Enter student name" << endl; cin >> name; } //display summary report

Solutions

Expert Solution

//please rate my solution hope all your requirements are satisfied

#include<iostream>
#include<stdlib.h>
using namespace std;
struct student            //structure that stores student data
{
string name;
int marks;
char grade;
struct student *next;
}*start;
int main()
{
   int tot=-1,a_count=0,b_count=0,c_count=0,d_count=0,f_count=0;//differents counts required
   student* temp=new student();//dynamic memeory allocation
   start=temp;
while(temp->name!="//")
{
cout << "Enter student name: ";
cin >> temp->name;
tot++;                   //count of students
if(temp->name=="//")
{
           temp->next=NULL;    //indicates last student
       }
       else
       {
   cout << "Enter score: ";
   cin >> temp->marks;
   int mark=temp->marks;
   if(mark>=90 and mark<=100)       //taking grade according to score
   {
       temp->grade='A';
       a_count++;
   }
   else if(mark>=80 and mark<=89)
   {
       temp->grade='B';
       b_count++;
   }
   else if(mark>=70 and mark<=79)
   {
       temp->grade='C';
       c_count++;
   }
   else if(mark>=60 and mark<=69)
   {
       temp->grade='D';
       d_count++;
   }
   else if(mark>=0 and mark<=59)
   {
       temp->grade='F';
       f_count++;
   }
  
   cout<<temp->name<<"\t"<<temp->grade<<"\t"<<temp->marks<<"\n";
  
   student* temp1=new student();
   temp->next=temp1;
   temp=temp->next;
   }
}
//temp=start;
cout<<"\nTotal Student count: "<<tot<<"\n";
cout<<"A students count: "<<a_count<<"\n";
cout<<"B students count: "<<b_count<<"\n";
cout<<"C students count: "<<c_count<<"\n";
cout<<"D students count: "<<d_count<<"\n";
cout<<"F students count: "<<f_count<<"\n";
  
}

Output:


Related Solutions

Write a program that translates a letter grade into a number grade. Letter grades are A,...
Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1 and 0. There is no F+ or F-. A “+” increases the numeric value by 0.3, a “–“ decreases it by 0.3. However, an A+ has value 4.0.4 pts Enter a Letter grade: B- The numeric value is 2.7 Your code with comments A screenshot...
c++ class Topics Branches if statement if/else statement Description Write a program that will determine whether...
c++ class Topics Branches if statement if/else statement Description Write a program that will determine whether the user passed or failed a test. The program will ask the user to input the following: Maximum Test Score - the maximum total scores in the test. Percent Pass Score - the minimum percent scores required to pass the test. User Test Score - the actual scores obtained by the user in the test. From the above input values, the program will compute...
Write a program that asks the user to enter 3 grades and computes the minimum and...
Write a program that asks the user to enter 3 grades and computes the minimum and the maximum of those 3 grades and prints it. Hint: Use the Math.min() and Math.max() methods. This program will compute the smallest and highest of 3 grades entered by the user. Enter 3 grades separated by a space: 100 85.3 90.5 Smallest: 85.3 Highest: 100.0 Bye
Write a program that will calculate numerical and letter grades for a student and output a...
Write a program that will calculate numerical and letter grades for a student and output a report: The information will be in the provided data file studentGrades.txt. The data file consists of several rows of data containing a student name and information for 3 types of assignments: First Name, Last Name, number of homework grades, values for homework grades, percentage of total grade, number of program grades, values for program grades, percental of total grade, number of ex-am grades, values...
Write a program that will calculate numerical and letter grades for a student and output a...
Write a program that will calculate numerical and letter grades for a student and output a report: The information will be in the provided data file studentGrades.txt. The data file consists of several rows of data containing a student name and information for 3 types of assignments: First Name, Last Name, number of homework grades, values for homework grades, percentage of total grade, number of program grades, values for program grades, percental of total grade, number of ex-am grades, values...
c++ class homework Topics If/Else If statement Description Write a program that determines a student’s final...
c++ class homework Topics If/Else If statement Description Write a program that determines a student’s final grade in the course. The course had three tests (100 points each) and four assignments (also 100 points each). All the test scores make up 70% of the grade and all the assignments 30% of the grade. The program asks the user to input one by one each of the test scores and each of the assignment scores. From these scores, it computes the...
In C program, Use "do...while" and "for" loops to write a program that finds all prime...
In C program, Use "do...while" and "for" loops to write a program that finds all prime numbers less than a specified value.
Write a program that uses loops (both the for-loop and the while loop). This assignment also...
Write a program that uses loops (both the for-loop and the while loop). This assignment also uses a simple array as a collection data structure (give you some exposure to the concept of data structure and the knowledge of array in Java). In this assignment, you are asked to construct an application that will store and retrieve data. The sequence of data retrieval relative to the input is Last In First Out (LIFO). Obviously, the best data structure that can...
You are to write a program that grades students (Maybe I will use it on you)....
You are to write a program that grades students (Maybe I will use it on you). Your program must open and read in "input.txt" (an example of which is below). It will contain the students name and their test scores. You are to calculate the students final grade in the course. Take the average of their test scores and output their average to a file with the below format. For the output.txt ensure that the formatting is in the block...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT