0% found this document useful (0 votes)
93 views

Subject Code: Name: Aditya Kumar Panda Section: D2010 Regd. No.: 12013730 Rollnumber: Rd2010B85

The document describes an object oriented program in C++ for a shopping mall application. The program allows the user to select between purchasing only an LED TV, an LED TV with a dish connection, or a normal television. The program displays the available products and their prices, applies any discounts, and generates a final bill. It implements classes for items, discounts, and generates output.

Uploaded by

aditya panda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views

Subject Code: Name: Aditya Kumar Panda Section: D2010 Regd. No.: 12013730 Rollnumber: Rd2010B85

The document describes an object oriented program in C++ for a shopping mall application. The program allows the user to select between purchasing only an LED TV, an LED TV with a dish connection, or a normal television. The program displays the available products and their prices, applies any discounts, and generates a final bill. It implements classes for items, discounts, and generates output.

Uploaded by

aditya panda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CA-1

Subject: OBJECT ORIENTED PROGRAMMING USING C++ LAB

Code: CAP:445
Name: Aditya Kumar Panda

Section: D2010

Regd. No.: 12013730

RollNumber: RD2010B85
Q1. Write a program for shopping mall, in shopping mall, there is an LED shop, User is given various offers on the
purchase of LED if you will purchase LED with television connection you will get 10% discount, but if you
purchase any LED you will get only 5 % discount. Display this offer to the user screen whenever user is
selecting the option. Also generate the final user bill after purchase with actual amount, discount and billing
amount.Select option:

1. Only LED

2. LED and dish connection

3. Normal television

#include<iostream>
#include<string>
using namespace std;

class item //Create class item


{
public:
int itemno[6]={100,101,102,103,105,106}; //Array of product itemno
int price[6]={10000,15000,12000,16700,8000,9000}; //array of product price
string name[6]={"Samsung 32\" LED Smart TV","Sony 42\" LED Smart TV",
"Samsung 32\" LED Smart TV with Airtel Dish TV","Sony 42\" LED Smart TV with Dish TV",
"samsung 53CM CRT tv","LG 80CM CRT TV"}; //String array of product name
int category[6]={1,1,2,2,3,3};
/* Category array to filter the product 1. for Only LED, 2. for LED and dish connection and 3. for Normal televi
sion */

};

class discount: public item


{
public:
int discount_percent;
int discounted_price,item_price, total_price;
int product_no;
string item_name;

int display(int ch) //to display the product list and select the product
{

int i;
cout<<"====================================================="<<endl;
cout<<"Item No"<<"\t\t"<<"Name"<<"\t\t\t"<<"Price"<<endl;
cout<<"====================================================="<<endl;
for(i=0;i<6;i++)
{
if(ch==category[i])
{

cout<<itemno[i]<<"\t\t"<<name[i]<<"\t"<<price[i]<<endl;
}

cout<<"\nEnter the Item No. you want to buy: ";


cin>>product_no;
return product_no;

void calculate(int product_no, int x) //To calculate the product price and discount
{

for(int i=0;i<6;i++)
{
if(itemno[i]==product_no)//to select the product from the product list
{
discount_percent=x;
item_name=name[i];
item_price=price[i];
discounted_price=price[i]*discount_percent/100;
total_price=item_price-discounted_price;
}
}
}
void showbill() //to show the bill
{
cout<<"--------------------------------\n";
cout<<"item no: "<<product_no<<endl;
cout<<"Item Name: "<<item_name<<endl;
cout<<"Actual Price: "<<item_price<<endl;
cout<<"Discount: "<<discount_percent<<"%"<<endl;
cout<<"Total Price: "<<total_price<<endl;
}
};

int main()
{
discount dis;
int choice,exit,product_no;
cout<<"\n\n\tWelcome to the Aditya LED Shop \n"<<endl;
cout<<"******************************************************\n";
cout<<"At the time we have offer "<<endl;
cout<<"-> If you have buy LED TV with Dish Connection get FLAT 10% Discount"<<endl;
cout<<"-> And if you buy Only LED TV you get FLAT 5% Discount\n";
cout<<"******************************************************\n\n";

do
{
exit=0;
cout<<"Select any of the product category\n";
cout<<" 1. Only LED\n 2. LED and dish connection \n 3. Normal television\n";
cout<<"\nEnter your choice(1-3): ";
cin>>choice;
if(choice==1)
{
product_no=dis.display(1); //display the Only LED product list
dis.calculate(product_no,15);
dis.showbill();

}
else if(choice==2)
{
product_no=dis.display(2); //display the LED and dish connection product list
dis.calculate(product_no,10);
dis.showbill();
}
else if(choice==3)
{
product_no=dis.display(3); //display the Normal Television product list
dis.calculate(product_no,0);
dis.showbill();
}
else
{
cout<<"Please enter the correct choice(1-3)";
exit=1;
}
}
while(exit==1); //To check the invalid input
return 0;

}
Output:-

Q2. A person having account in a bank. His balance in bank account is 50000. He is also getting 2000 Rs.
from PM Fund every month and 5% of interest on the amount saved quarterly. Create one application
where you have applied the concept of multiple inheritance which will display extra amount he is getting
annually?

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

class monthly //class for monthly balace credited


{
int n=4; //quarter
double p; //principle amount credited monthly
float rate=0.05; //intrest rate
double months=12.0; //total months in a year
double monthly_deposit, monthly_balance=0,a,b=0;
public:
void input_monthly() //to enter the monthly how much amount credited like pmfunds
{
cout<<"Enter the monthly amount credited: ";
cin>>p;
}
double calc_monthly()//to calculate total monthly income anually
{
for(int i=1;i<=12;i++)
{
a=p*pow((1+rate/n),(n*i/months)); // 2000*pow((1+0.05/4),(4*i/12)
monthly_deposit+=p;
monthly_balance+=a;
}
return monthly_balance-monthly_deposit;
}
};

class balance //class for balance available at the time


{
int quater=4;
float rate=0.05; //intrest rate
double p; //principle amount
double a;

public:
double input_balance()
{
cout<<"Enter the balnce available at the time: ";
cin>>p;
}
double calc_balance()
{
a=p*pow((1+rate/quater),quater);
return a-p;
}
};

class bank:public monthly,public balance


{
double total_interest, monthly_interest, balance_interest;
public:
void calc() //driver program
{
input_monthly();
input_balance();
monthly_interest=calc_monthly();
balance_interest=calc_balance();

total_interest=monthly_interest+balance_interest;
}
void show() //to show the total interest
{
cout<<"You total interest annually get: "<<total_interest;
}
};
int main()
{
bank aditya;
aditya.calc();
aditya.show();
}

Output:
Q3 Write a program to overload copy constructor and parameterized constructor with default arguments.
Implement the concept of finding a number is Armstrong in the same program.

#include<iostream>
using namespace std;

class aditya //Create class aditya


{
public:
int num=0,temp;
aditya(int x=153)//default constructor with default arguments
{
num=x;
}
aditya(const aditya &a)//copy constructor
{
temp=a.num;
}

void checkArmstrong() //function to check number is armstrong or not


{

int r;
while (temp > 0)
{
r = temp % 10;
num = num + r * r* r;
temp = temp/10;
}
}
};

int main()
{

int x;
cout << "Enter a number: ";
cin>>x;

aditya a(x); //Default constructor is called here

aditya b=a; //copy constructor is called here

b.checkArmstrong(); //calling checkArmstrong()

if(a.num==b.num)
cout<<"Number is armstrong: "<<a.num;
else
cout<<"Number is not armstrong: "<<a.num;

return 0;
}

Output:

You might also like