11-15-2014, 03:52 PM
/*Assignment No 1 cs304 object oriented programming.
This program consists of student and instructor classes*/
#include <iostream>
#include <cstdlib>
#include <string.h>
#include <stdlib.h>
using namespace std;
//starting the student class
class Student{
private:
char * StudentID;
char * StudentName;
public:
Student(char *, char *);
void print(); //parametarized constructor of student class
~Student(); //destructor of student class
};
Student::Student(char *id, char *name)
{
StudentID = id;
StudentName = name;
}
void Student::print()
{
cout "Student ID : " StudentID endl;
cout "Student Name : " StudentName "\n\n";
}
Student::~Student()
{
}
class Instructor{
private:
float age[8];
public:
Instructor(){ }
~Instructor(){ }
void input();
void print();
};
void Instructor::input()
{
int i;
for(i=1; i<=8; i++)
{
cout "Please enter the age of " i " Instructor in Feet : ";
cin >> age[i];
cout "\n\n";
}
}
void Instructor::print()
{
int i;
float totalage = 0, averageage = 0;
for(i=1; i<=8; i++)
{
totalage+=age[i];
}
averageage = totalage/8;
cout "Average Height in Feet : " averageage;
}
main()
{
Student student1((char *)"BC0000000000", (char *)"xxxxxxxxxxx");
student1.print();
Instructor heights;
heights.input();
heights.print();
cout "\n\n";
system("pause");
}
This program consists of student and instructor classes*/
#include <iostream>
#include <cstdlib>
#include <string.h>
#include <stdlib.h>
using namespace std;
//starting the student class
class Student{
private:
char * StudentID;
char * StudentName;
public:
Student(char *, char *);
void print(); //parametarized constructor of student class
~Student(); //destructor of student class
};
Student::Student(char *id, char *name)
{
StudentID = id;
StudentName = name;
}
void Student::print()
{
cout "Student ID : " StudentID endl;
cout "Student Name : " StudentName "\n\n";
}
Student::~Student()
{
}
class Instructor{
private:
float age[8];
public:
Instructor(){ }
~Instructor(){ }
void input();
void print();
};
void Instructor::input()
{
int i;
for(i=1; i<=8; i++)
{
cout "Please enter the age of " i " Instructor in Feet : ";
cin >> age[i];
cout "\n\n";
}
}
void Instructor::print()
{
int i;
float totalage = 0, averageage = 0;
for(i=1; i<=8; i++)
{
totalage+=age[i];
}
averageage = totalage/8;
cout "Average Height in Feet : " averageage;
}
main()
{
Student student1((char *)"BC0000000000", (char *)"xxxxxxxxxxx");
student1.print();
Instructor heights;
heights.input();
heights.print();
cout "\n\n";
system("pause");
}
0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
