In: Computer Science
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
//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";
}