Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.


 

Assignment No. 4
Semester: Fall 2010

CS201: Introduction to Programming 

Total Marks: 20

 

Due Date: 24th Jan, 2011

 

Instructions:

Please read the following instructions carefully before submitting your 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.

 

All types of plagiarism are strictly prohibited.

 

Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted. If you will submit code any other file format like .doc or .txt etc. you will get zero marks.

 

Objective

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

 

§         Classes and objects manipulation in c++

§         Operators overloading

 

Guidelines

§         Code should be properly aligned and well commented.

§         Follow C/C++ rules while writing variables names, function names etc.

§         Use only Dev-C++ IDE for this assignment.

 

Assignment

 

 

Problem Statement: Price manipulation

 

You are required to create a class in C++ named Price with the following Data members, Data members should be publicly declared.

 

  • Rupees
  • Paisas

 

The Price class presents Price in Rupees and Paisa. For instance, Price (10, 80) means 10 rupees and 80 paisas. The Price class should have the following features as described in detailed descriptions:

 

Detailed Description:

Constructors

 

Class Price must have

 

  • Default constructor, which must set Rupees and Paisas to zero.

 

  • Parameterized constructor that receives two parameters of type int and initializes its private data: Rupees and Paisas with them. Note that if Paisas are 100 or greater than 100 then also convert it in Rupees.

Member Functions

  • Create a function named Print()that displays the price of object in terms of rupees and paisas.

Operator overloading

  • A member function that overloads the + Operator to add two objects of Price.

 

There should be an overloaded + operators:

 

  • Add two objects and return Price object. Note that Paisas should not exceed 100.
  • Add first number into second objects and return Price object. Note that paisas should not exceed 100.

 

 

Output of your program should be as follows:

 

Price is 10 rupees and 60 paisas

 

Price is 12 rupees and 80 paisas

 

After Addition

 

Price is 23 rupees and 40 paisas

 

 

 

Note: you have to use same Class and Function name as mentioned in the assignment details. If we find any deviation, marks will be deducted.

 

Deadline:

Your Assignment solution must be submitted on or before January 24th, 2011.

 





Only CPP file will be accepted, file other than CPP will be awarded zero (0) marks.

 

Views: 564

Attachments:

Replies to This Discussion

Yah loo bhaiyoo assignment No.4 ka solution
Attachments:
G
#include <iostream.h>
#include <conio.h>
                        // This is only for IDEA, not a complete solution.
class price
{
  public:
    int rupees, paisas;
    price () {};
    price (int,int);
    price operator + (price);
};

price::price (int x1, int y1)
{
  rupees = x1;
  paisas = y1;
}

price price::operator+ (price money)
{
  price convert;
  convert.rupees = rupees + money.rupees;
  convert.paisas = paisas + money.paisas;
  return (convert);
}

int main ()
{
  price x1 (10,60);
  price y1 (13,2);
  price z1;
  z1 = x1 + y1;
  cout "Price is "z1.rupees " rupees " "and "z1.paisas" paisas";
  getch();
  return 0;
}
i need cs201 correct solution
CS201 Assignment 4 solution fall 2010
Download the complete solution then complie it in Devc++
Attachments:

Execution problem after compilation

Please fix it and reupload cpp file

 

this solution create execution problem after compilation.

plz solve this problem sir

correct solution!!!

#include <iostream.h>
#include <conio.h>
class price{
//Declaring private data members
private:
int rupies;
int paisas;
//Declaring public functions
public:
price(); //Default constructor
price (int,int); //Overloaded constructor
void Print(); //print function for displaying the array elements
price operator+(price); //Operator overloading function for operator +
};

// Default constructor
price::price()
{
rupies = 0;
paisas = 0;
}

// Overload constructor
price::price(int crupies, int cpaisas)
{
rupies = crupies;
paisas = cpaisas;
}

//Function to display the elements
void price::Print()
{
cout" Price is "rupies" Rupees and "paisas" Paisas " endl;
}

// Function for + operator overloading
price price::operator+(price d2)
{
int r = rupies + d2.rupies; //adding rupeies
int p = paisas + d2.paisas; //adding paisas
if (p>=100) //If paisas exceeds from 100 then adding a
{
p-=100; // them into rupies
r++;
}
return price (r,p);
}

int main()
{
price result;
price obj1(10, 60);
price obj2 (12, 80);
result = obj1+obj2;
obj1.Print();
cout"\n";
obj2.Print();
cout"\n";
cout"After Addition\n\n";
result.Print();
getch();
}

this assignment is correct but according to asignmnt ruppes and paisas shud be publicaly declared

i did dat but nw i thnk cz of dis its dispalyn like this:

Price is 12 rupees and 80 paisas

 

Price is 12 rupees and 80 paisas

 

After Addition

 

Price is 23 rupees and 40 paisas

 

mean same numbers

hw to correct dat?

PLZZZZZZZZZZZZZZ TELL ME

TARIQ BHAI GUIDE PLZ

see the attached file for another idea solution
Attachments:
None of these is working well.

sir wtz da rite solution?

 

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service