63 838
Assignments Done
99,2%
Successfully Done
In August 2018

Answer to Question #24371 in C++ for ruhul amin pathan

Question #24371
Write a C++ program that interacts with the user to read data for N students, stores them in an array and
then prints them out. You need to create a Student class that can hold the name, id, and date of birth of a
student. The program will essentially be similar to the BankAccount class demo that I will show in
class today. However, for each student you need to compute his/her age given the date of birth
information.
Sample Execution
Enter the number of students to process
2
Enter the name of student #1
Abul
Enter the ID of student #1
2013000000901
Enter the date of birth of student #1 (dd mm yyyy)
05 01 1995
Enter the name of student #2
Babul
Enter the ID of student #2
2013000000912
Enter the date of birth of student #2 (dd mm yyyy)
12 05 1994
The database recorded information about 2 students
Student #1
Name: Abul
ID: 2013000000901
Age: 18 years, 1 months, and 2 days
Student #2
Name: Babul
ID: 2013000000912
Age: 18 years, 8 months, and 25 days
Expert's answer
# include <iostream>
# include <string >
using namespace std;
const int Cday=14,Cmonth=2,Cyear=2013;

class stud{
private:
string name;
string ID;
int day, mon, year;
public:
void in(){
cout<<"Enter name:";
getline(cin,name,'\n');
cout<<"ID:";
getline(cin,ID,'\n');
cout<<"enter date";
cout<<"day:";
cin>>day;
cout<<"month:";
cin>>mon;
cout<<"year:";
cin>>year;
}
void print(){
cout<<"Name:"<<name;
cout<<"\nID:"<<ID;
int cur;
cur=(Cyear-year)*365+(Cmonth-mon)*30+(Cday-day);
cout<<"\nAge:"<<cur/365<<" year "<<(cur%365)/30<<" month "<<((cur%365)%30)<<" days\n";
}


};
int main(){

stud a;
a.in();
a.print();

system("PAUSE");
return 0;
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions