C Students Data Program Create a program to store informati

C++ Students Data Program ---------------------- Create a program to store information about students and then print it to the screen. Requirements: 1) The user will decide for how many students he wants to enter information 2) The program must accept the following information for each student: - First name - Last name - Gender (accept both m/f and M/F) - Age - Height (inches) 3)For each student, print the data to the screen in tablular, left-justified format (hint: use iomanip functions)

Example of program execution Please enter student 2\'s First Name: Joan

Please enter Joan\'s Last Name: Jett

Please enter Joan\'s Gender: F

Please enter Joan\'s Age: 20

Please enter Joan\'s height (inches): 67

Student 2 --------- Jett, Joan Female

20years old 5\' 7\"

Solution

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
typedef struct student
{
   char firstName[20];
   char lastName[20];
   char gender;
   int age;
   int heightInInches;

}STUDENT;

int main()
{
   int numberOfStudent,i;
   cout<<\"please enter number of stuent\"<<endl;
   cin>>numberOfStudent;
   STUDENT *dataStorage=new STUDENT[numberOfStudent];
   for(i=0;i<numberOfStudent;i++)
   {
       cout<<\"please enter student\"<<i+1<<\"\'s\"<<\" First Name: \";
       cin>>dataStorage[i].firstName;
       cout<<\"Please enter \"<<dataStorage[i].firstName<<\"\'s Last Name: \";
       cin>>dataStorage[i].lastName;
       cout<<\"Please enter \"<<dataStorage[i].firstName<<\"\'s Gender: \";
       cin>>dataStorage[i].gender;
       cout<<\"Please enter \"<<dataStorage[i].firstName<<\"\'s Age: \";
       cin>>dataStorage[i].age;
       cout<<\"Please enter \"<<dataStorage[i].firstName<<\"\'s height(inches): \";
       cin>>dataStorage[i].heightInInches;
       cout<<endl;

   }
   //cout<<left<<setw(15)<<\"serialNumber\"<<\"----\"<<left<<setw(20)<<\"LastName\"<<left<<setw(20)<<\"FirstName\"<<left<<setw(2)<<\"Gender\"<<left<<setw(3)<<\"Age\"<<left<<setw(4)<<\"heightInInches\"<<endl;
   for(i=0;i<numberOfStudent;i++)
   {
       string gen;
       if(dataStorage[i].gender==\'m\'||dataStorage[i].gender==\'M\')
           gen=\"male\";
       else
           gen=\"female\";
       cout<<\"Student\"<<i+1<<\"---- \"<<left<<setw(20)<<dataStorage[i].lastName<<left<<setw(20)<<dataStorage[i].firstName<<left<<setw(7)<<gen<<left<<setw(3)<<dataStorage[i].age<<\"years old \"<<left<<setw(4)<<dataStorage[i].heightInInches<<endl;
   }
   delete dataStorage;
   return 0;
}
/*
output:
please enter number of stuent
2
please enter student1\'s First Name: anwar
Please enter anwar\'s Last Name: khan
Please enter anwar\'s Gender: m
Please enter anwar\'s Age: 20
Please enter anwar\'s height(inches): 22

please enter student2\'s First Name: ram
Please enter ram\'s Last Name: prasad
Please enter ram\'s Gender: f
Please enter ram\'s Age: 33
Please enter ram\'s height(inches): 33

Student1---- khan anwar male 20 years old 22
Student2---- prasad ram female 33 years old 33
*/

C++ Students Data Program ---------------------- Create a program to store information about students and then print it to the screen. Requirements: 1) The user
C++ Students Data Program ---------------------- Create a program to store information about students and then print it to the screen. Requirements: 1) The user

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site