Write program that reads some information of 10 students (name [max 15] , level number , #of points , #of hours , GPA , student id ). These fields should be filled for each student by user except GPA. The GPA (max: 5) should be calculate it by function that takes #of points , #of hours as arguments and return the value of GPA.
Using small menu, the user can done some operations:
1. print all information for specific name
2. print all students names and ids that their GPA more than 4
3. sort the students information using student name
4. exit
here is the code
#include<iostream.h>
#include<string.h>
float fun(float arr[][1],float arr[][3]){
arr[i][5]=(arr[i][1]/arr[i][2]);
return arr[i][5];}
int main(){
char ch,temp;
int i,b,a,num;
char arr_name[10];
float arr[10][5];
cout<<"this is a small menu to show what this program do\n";
cout<<"to use this program you should use the same order of \n";
cout<<"the menu......\n";
cout<<" *^*^*^*****^*^*^*\n";
do{
cout<<"1. print all information for specific name.\n";
cout<<"2. prints all student's names and id's that their GPA more than 4.\n";
cout<<"3. sort the student information using the student's name.\n";
cout<<"4. exit.\n";
cin>>num;
switch(num){
case 1 :for(i=0;i<10;i++){
cout<<"enter the name for student "<<i<<endl;
gets(arr_name[ch]);
cout<<"enter the student's level number: ";
cin>>arr[i][0];
cout<<"enter the student;s points of all classes: ";
cin>>arr[i][1];
cout<<"enter the students hours of all classes: ";
cin>>arr[i][2];
cout<<"enter the student's id number: ";
cin>>arr[i][3];
arr[i][5]=fun(arr[][1],arr[][2]);
cout<<"the GPA for student number "<<i<<" is "<<arr[i][5]<<endl;
}
break;
case 2 :for(i=0;i<10;i++){
if(arr[i][5]>4)
cout<<"the student's name is : "<<arr_name[i]<<" id number: "<<arr[i][4]<<"\n";
}
break;
case 3 :for(i=0;i<10;i++){
for(a=0;a<10;a++){
for(b=9;b<=a;b--){
if (arr_name[b-1]>arr_name[b]){
temp=arr_name[b-1];
arr_name[b-1]=arr_name[b];
arr_name[b]=temp;}
}
}
cout<<arr_name[i];
}
break;
case 4 :cout<<"thank you for visiting this program\n";
break;
}while(num!=4);
return 0;
}
}
<< moderator edit: added [code][/code] tags -- start doing this yourself >>