Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CS304 Object Oriented Programming Assignment No:1 Discussion November 2014
#1

CS304 Object Oriented Programming Assignment No:1 Discussion November 2014


[TABLE="width: 748, align: center"]
[TR]
[TD="colspan: 2"]Instructions:

Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:

§ The assignment is submitted after due date.
§ The submitted assignment does not open or file is corrupt.
§ Assignment is copied(partial or full) from any source (websites, forums, students, etc)

Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files or .exe file, no reward will be given in any case.


Objective:

The objective of this assignment is to provide hands on experience of:

§ Basic concepts of classes and objects in C/C++ language
§ Dealing with member functions
§ Dealing with Constructors
§ Calling member functions through objects of classes
§ Saving a program
§ Compiling a program
§ Executing the program

Guidelines:

§ Code should be properly indented and well commented.
§ Follow C/C++ guide lines while writing variable names, function names etc
§ Use only dev-C++ for this assignment.



[/TD]
[/TR]
[TR]
[TD]Assignment[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"]Problem Statement:
Write the C++ language program that should fulfill the following requirements:
Program should contain two classes as “Student” and “Instructor”. Within main() function, create the objects of these two classes. Display your student ID and name by passing as attributes(student ID, name) while instantiating the object of the “Student” class. Using the object of the Instructor Class, call its member function Input() to take input for the height of the 8 instructors then call its member function print() to display the average height of the instructors.
Declare data members by private and member functions by public access specifier for both classes.

[TABLE="align: center"]
[TR]
[TD]Function[/TD]
[TD]Description[/TD]
[/TR]
[TR]
[TD]main() function[/TD]
[TD]Objects of both classes will be created in it, and respective member functions of these objects will be called.[/TD]
[/TR]
[TR]
[TD]Student(char *, char *)[/TD]
[TD]Constructor of the Student class to display your own student ID and name[/TD]
[/TR]
[TR]
[TD]input()[/TD]
[TD]Function of Instructor class , it will take heights as input of 8 instructors[/TD]
[/TR]
[TR]
[TD]print()[/TD]
[TD]Function of Instructor class, it will display average height of 8 instructors.[/TD]
[/TR]
[/TABLE]


Detailed Description:

Your program should display your own student ID and name on the top of the screen through passing as attributes at the time of instantiating object of the Student class i.e.
Student ID : MC104403787
Student Name : Rehman

Member function input() of the “Instructor” class should take height as input of the 8 instructors from the user i.e.

Enter Instructor 1 Height in Feet : 5.5

Member function print() of the “Instructor” class should display average height of the Instructors.
Sample output of the program:

[/TD]
[/TR]
[/TABLE]



[Image: attachment.php?attachmentid=24082&stc=1]



Attached Files
.jpg   Untitled.jpg (Size: 39.55 KB / Downloads: 1,027)
Reply
#2
/*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");
}

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply
#3
Any question do register for cs304 and ask the admin for the solution if u don't understand it.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cs403 Assignment 3 Helping material May 8,2010 viki 1 5,196 04-28-2020, 03:19 PM
Last Post: ClaireBeauc
  cs301 assignment no 3 Solution 20 January 2016 Vuhelper 0 11,086 01-20-2016, 03:32 PM
Last Post: Vuhelper
  CS201 Assignment vo 3 Solution 20th January 2016 Vuhelper 2 2,593 01-20-2016, 03:28 PM
Last Post: Vuhelper
  CS101 Assignment no 3 Solution 20th January 2016 Vuhelper 0 2,278 01-20-2016, 03:25 PM
Last Post: Vuhelper
  SOC101 INTRODUCTION TO SOCIOLOGY assignment no 3 Solution 20 January 2016 Vuhelper 0 1,868 01-20-2016, 03:19 PM
Last Post: Vuhelper
  CS402 Assignment No 4 Solution & Discussion Xpert 0 2,093 08-01-2015, 02:33 AM
Last Post: Xpert
  cs101 Assignment No. 1 Solution 21 may spring 2015 semester Xpert 0 2,907 05-21-2015, 12:41 AM
Last Post: Xpert
  Assignment solution eng 301 due date 20 may 2015 rumesa khan 3 4,526 05-20-2015, 01:34 AM
Last Post: Xpert
  PHY301 Circuit Theory Assignment No. 1 idea Solution spring may 2015 semester Xpert 0 1,557 05-15-2015, 03:52 AM
Last Post: Xpert
  Assignment No. 01 Spring 2015 Information Systems CS507 idea solution spring 2015 Xpert 0 2,445 05-15-2015, 03:49 AM
Last Post: Xpert

Forum Jump:


Users browsing this thread: 1 Guest(s)