Assignment 7
Assignment 7
Assignment 7
Question 1
Ans:
PROGRAM:
#include <iostream>
using namespace std;
class one_d
{public:
int x;
one_d(int a)
{x=a;
}
one_d()
{x=0;
}
void display(void)
{cout<<"x coordinate: "<<x<<endl;
}
};
class two_d: public one_d
{public:
int y;
two_d()
{x=0;
y=0;
}
two_d(int a,int b)
{y=b;
x=a;
}
void display(void)
2
a2.display();
cout<<"Enter 1 D coordinates: ";
cin>>a;
one_d a3(a);
a3.display();
}
OUTPUT:
Question 2:
Ans.:
PROGRAM:
#include<iostream>
using namespace std;
class Exchange
{protected :
double rs,exchangeRate,amount;
public:
double rupees,rate;
void convert();
void display();
Exchange()
4
{rs=rupees;
exchangeRate=rate;
}
};
class Rs_to_Dollar:public Exchange
{public:
Rs_to_Dollar()
{rate=70;
}
};
class Rs_to_Euro: public Exchange
{public:
Rs_to_Euro()
{rate=75;
}
};
void Exchange::convert()
{amount=rupees/rate;
}
void Exchange::display()
{cout<<"The amount is "<<amount<<endl;
}
int main()
{Rs_to_Dollar A;
Rs_to_Euro B;
cout<<"Please enter the amounts to be converted"<<endl;
cin>>A.rupees>>B.rupees;
cout<<" for Dollars: ";
A.convert();
A.display();
cout<<" for Euros: ";
B.convert();
B.display();
5
OUTPUT:
Question 3:
Ans:
PROGRAM:
#include <iostream>
using namespace std;
class Employee
{public:
int pan, taxin;
string name;
void inputdata(void)
{cout<<"Enter name :";
cin>>name;
cout<<"Enter PAN: ";
cin>>pan;
cout<<"Enter taxable income: ";
cin>>taxin;
}
void displaydata(void)
6
Taxcalc t;
e.displaydata();
t.computetax(e.taxin);
}
}
OUTPUT: