plz send the solution till tomorrow

Assignment No. 5

Deadline

Your assignment must be uploaded/submitted before or on 30th June, 2004.

Uploading instructions

Please view the assignment submission process document provided to you by the Virtual University to upload the assignment.

Rules for Marking

It should be clear that your assignment will not get any credit if:

o The assignment is submitted after due date
o The submitted assignment does not compile or run
o The assignment is copied


Objective

This assignment has been designed so that you understand the concept of classes in C++. After the completion of this assignment you should have a good grasp on:

o Writing classes in C++.
o Accessing the data members of the class, using member functions.


Assignment

Write a C++ program that calculates a student’s fine meant for being absent in one month. Make a class named Fine having following data members:

//for name of the student
o student_name

//for number of days the institute is on in a month time
o on_days

//for number of days the student was present in a month time
o present_days

//for fine per day
o fine_per_day


If a user enters number of present days that are greater than on days, the program exits after displaying the following message;

o Days present should not be greater than on days of the month.


Class Fine should also contain the following member function:
o mothly_fine ( );

This function will first calculate number of days; the student was absent in a month and then calculates the monthly fine by multiplying the number of absent days by fine per day.


Write the Setter functions to set or assign values to all data members of the Class.

Write the Getter functions to get value of all data members of the Class.

Create an object of type Fine in main and call the monthly_fine( ) function to find out the monthly fine against that particular object.

Initialize the data members of the class by their default values in the constructor’s definition, when the object is instantiated.

Use Destructor when the object is destroyed.

Display the message “constructor called” in the constructor definition.
Display the message “destructor called” or “The object has been destroyed” in the destructor definition.


Sample input:


Constructor called

Enter student’s name: Razia

Enter total on days of the month: 28

Enter number of days the student was present: 20

Enter fine per day: 5.0




Student’s Name: Razia

On days: 28

Present days: 20

Per day fine: 5

Absent days: 8

Monthly Fine: 40


The object has been destroyed

Creating a new Project in the Dev C++ Environment
In order to create a new Project:
• Go to the "File" menu and select "New Project..."
• Choose "Empty Project", make sure "C++ project" is selected, and click "OK".
• At this point, Dev-C++ will ask you to give your project a name.
You can give your project any valid filename, but keep in mind that the name of your project will also be the name of your executable.
Adding source file(s)
By the method mentioned above you will have a project with one empty and untitled source file. You can create additional empty source files in one of two ways,
• Go to the "File" menu and select "New Source File" (or just press CTRL+U) OR
• Go to the "Project" menu and select "New Unit in Project" (or just press CTRL+F1).
Note that Dev-C++ will not ask for a filename for any source file until you attempt to:
1. Compile
2. Save the project
3. Save the source file
4. Exit Dev-C++

Assignment submission instructions:

Your Assignment should be in the form of a project. Make a Project in Dev–C++, write your code in the .cpp file and add it in your project. For more help you can view the handout on project at LMS on lesson # 26.
You should submit the .dev and .cpp file in the form of a Zip file.

Assignment No. 5

Deadline

Your assignment must be uploaded/submitted before or on 30th June, 2004.

Uploading instructions

Please view the assignment submission process document provided to you by the Virtual University to upload the assignment.

Rules for Marking

It should be clear that your assignment will not get any credit if:

o The assignment is submitted after due date
o The submitted assignment does not compile or run
o The assignment is copied


Objective

This assignment has been designed so that you understand the concept of classes in C++. After the completion of this assignment you should have a good grasp on:

o Writing classes in C++.
o Accessing the data members of the class, using member functions.


Assignment

Write a C++ program that calculates a student’s fine meant for being absent in one month. Make a class named Fine having following data members:

//for name of the student
o student_name

//for number of days the institute is on in a month time
o on_days

//for number of days the student was present in a month time
o present_days

//for fine per day
o fine_per_day


If a user enters number of present days that are greater than on days, the program exits after displaying the following message;

o Days present should not be greater than on days of the month.


Class Fine should also contain the following member function:
o mothly_fine ( );

This function will first calculate number of days; the student was absent in a month and then calculates the monthly fine by multiplying the number of absent days by fine per day.


Write the Setter functions to set or assign values to all data members of the Class.

Write the Getter functions to get value of all data members of the Class.

Create an object of type Fine in main and call the monthly_fine( ) function to find out the monthly fine against that particular object.

Initialize the data members of the class by their default values in the constructor’s definition, when the object is instantiated.

Use Destructor when the object is destroyed.

Display the message “constructor called” in the constructor definition.
Display the message “destructor called” or “The object has been destroyed” in the destructor definition.


Sample input:


Constructor called

Enter student’s name: Razia

Enter total on days of the month: 28

Enter number of days the student was present: 20

Enter fine per day: 5.0




Student’s Name: Razia

On days: 28

Present days: 20

Per day fine: 5

Absent days: 8

Monthly Fine: 40


The object has been destroyed

Creating a new Project in the Dev C++ Environment
In order to create a new Project:
• Go to the "File" menu and select "New Project..."
• Choose "Empty Project", make sure "C++ project" is selected, and click "OK".
• At this point, Dev-C++ will ask you to give your project a name.
You can give your project any valid filename, but keep in mind that the name of your project will also be the name of your executable.
Adding source file(s)
By the method mentioned above you will have a project with one empty and untitled source file. You can create additional empty source files in one of two ways,
• Go to the "File" menu and select "New Source File" (or just press CTRL+U) OR
• Go to the "Project" menu and select "New Unit in Project" (or just press CTRL+F1).
Note that Dev-C++ will not ask for a filename for any source file until you attempt to:
1. Compile
2. Save the project
3. Save the source file
4. Exit Dev-C++

Assignment submission instructions:

Your Assignment should be in the form of a project. Make a Project in Dev–C++, write your code in the .cpp file and add it in your project. For more help you can view the handout on project at LMS on lesson # 26.
You should submit the .dev and .cpp file in the form of a Zip file.


Comments

  • you gott'a be shi**ing me! you want us to do your homework for you???
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion