Write a complete program with the following: 1. A function named getID that asks
ID: 3643575 • Letter: W
Question
Write a complete program with the following:1. A function named getID that asks the user to enter a student ID and returns that ID as an integer
2. A function named getScores that accepts an integer named ID and asks the user to enter 4 scores for the
student with that ID, and returns the total scores as an integer.
3. A void function named getGrade, that accepts total (an int) and grade (a char) that sets grade to A, B, C,
or D, respectively if total is 90 or higher, 80 or higher, 70 or higher, or 60 or higher, otherwise, grade is set to F.
4. A void function named printGrade that accepts ID, total, and grade, and displays the student ID,
total, and grade. 5. The main function calls each of the above functions.
6.place the function calls into a loop that asks the user if he wants to input another student
Explanation / Answer
Please rate...
#include<iostream>
using namespace std;
int getID()
{
int a;
cout<<"Enter the student ID: ";
cin>>a;
return a;
}
int getScores(int id)
{
int a,b,c,d,e;
cout<<" Enter the 4 scores of student ID "<<id<<" ";
cin>>a>>b>>c>>d;
e=a+b+c+d;
return e;
}
void getGrade(int t,char *c)
{
if(t>=90)*c='A';
else if(t>=80 && t<90)*c='B';
else if(t>=70 && t<80)*c='C';
else if(t>=60 && t<70)*c='D';
else *c='F';
}
void printGrade(int id,int t,char g)
{
cout<<" The student ID is: "<<id;
cout<<" The total is: "<<t;
cout<<" The grade is: "<<g;
}
int main()
{
char a='y',b;
int id,s;
while(a=='y' || a=='Y')
{
id=getID();
s=getScores(id);
getGrade(s,&b);
printGrade(id,s,b);
cout<<" Do you want to enter another student(y for yes): ";
cin>>a;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.