Hello, I\'m doing my final project for my basic C++ class, and I have no idea wh
ID: 3535250 • Letter: H
Question
Hello, I'm doing my final project for my basic C++ class, and I have no idea where to start or what to do. I'll be glad if you guys can help me with this. These are the requirements for the project:
. Use C languge to create a students class socres management and statistic program. There are less than 10 students in the class. Each student have 5 diffeent class. The program will calculate the average score of each student's classes. Finally, the grading (A-F) is given according to the average score.
2. The flow of the program is as follows:
2.1 Ask user to input the student number, name, class number, class name, class score
2.2 Ask if it is ending to input, if it is yes, go to step 2.3, or go back to step 2.1 to input another student recorder.
2.3 Print out the student score result in the following format:
class 1 name class 2 name ..... class 5 name average grading
student1's name 78 80 ..... 90 88.5 A
student2's name 80 60 ....... 50 50 F
.......
Explanation / Answer
At first you said to write program in C++ and then in C, anyways I am writing my code in C++, if you want to the code in C then just tell me I will tell you to change one or to statements and the code gets converted in C language.. :)
Here is the code :)
#include <iostream>
#include <conio>
#include <string>
using namespace std;
int main ()
{
struct stu {
int n;
string name;
int cln[5];
string clname[5];
double score;
};
stu student[10];
double sum, avg[10];
char grd[10];
for (int i=0; i<10; i++)
{
cout<<"Enter the Student Number";
cin>>student[i].n;
cout<<"Enter the name of the Student whose number is : "<<student[i].n;
cin>>student[i].name;
sum=0;
for (int j=0; j<5; j++)//nested loop
{
cout<<"Enter the Class Number of the Student whose number is : "<<student[i].n;
cin>>student[i].cln[j];
cout<<"Enter the Class Name of the Student whose number is : "<<student[i].n<<" and the class number is : "<<student[i].cln[j];
cin>>student[i].clname[j];
cout<<"Enter the Score of the Student whose number is : "<<student[i].n<<" and the class number is : "<<student[i].cln[j];
cin>>student[i].score[j];
sum=sum+student[i].score[j];
}//end of nested loop
avg[i]=sum/5;
if(avg[i]>=90)
grd[i]='A';
if(avg[i]>=80 && avg[i]<90)
grd[i]='B';
if(avg[i]>=70 && avg[i]<80)
grd[i]='C';
if(avg[i]>=60 && avg[i]<70)
grd[i]='D';
if(avg[i]>=50 && avg[i]<60)
grd[i]='E';
if(avg[i]<50)
grd[i]='F';
int x;
cout<<"Do you want to continue entering the data for another student(maximum 10 student)?? Enter 1 to continue, 0 to cancel";
cin>>x;
if(x==0)
break;
}//end of loop
cout<<" Class1 name Class2 name Class3 name Class4 name Class5 name ";
for (int i=0; i<10; i++)
{
cout<<student[i].name<<" ";
for (int j=0; j<5; j++)//nested loop
{
cout<<student[i].clname[j]<<" ";
}//end of nested loop
cout<<avg[i]<<" "<<grd[i]<<" ";
}//end of loop
return 0;
}//end of program
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.