Answer to Question #16572 in C++ for nardeen

Question #16572
1- Write a C++ program to define a class for Student; the class should have three 3 private member variables name of type char array size 10, age of type integer, and GPA of type float. Have two constructors (one default no arguments and one with three values one for each member variable) and a setter and getter for each member variable, one destructor. Make sure to validate your input values inside setters and getters by checking age to be above 0, and GPA above 0 and less than or equal to 100.
Declare an array of five students
Declare a function to read values of the objects array
Declare a function to print the name of the student who has the maximum GPA.
1
Expert's answer
2012-10-16T11:35:18-0400
#include <string>
#include <fstream>
#include <iostream>
using namespace std;



int main()
{ int i=-1,k,f=0,a;
while(i<0 || i%2==0)
{
cout<<"enter an odd positive integer: ";
cin>>i;
}
for (a=0;a<i;a++){
& if(a!=(i-1)/2){
for (k=0;k<i;k++){
& if(k==f || k==(i-1-f))
& cout<<"0";
& else if (k==(i-1)/2)
& cout<<"-";
& else cout<<" ";
& }
cout<<"\n"; }
else {
for (k=0;k<i;k++){
if(k==(i-1)/2)
cout<<"0";
else
cout<<"-";
}
& cout<<"\n";&
}
f++;
}

cout<<"\n\n";
system("PAUSE");
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS