Professional Documents
Culture Documents
Assignment#03 Ali Haider 404674
Assignment#03 Ali Haider 404674
ALI HAIDER
404674
Q#1: Write a code in C++ to make an ATM machine. Use classes to
design your ATM software. Use operator overloading concept to
transfer money from one account to another account. Your code
should print the following output with the corresponding functionality.
#include<iostream>
#include<unistd.h>
class atm
private:
int pin;
char name[50];
int balance;
public:
};
void display_menu()
cout<<"|Press 12 To Exit"<<endl;
int main()
atm a;
int s,d,f,g,h1,h2,h3,h4,h5,h6,w,r=0;
int h7,y,x1,x2,x3,x4,h9,h8,h10,q,i,h11,h12;
char c[100],x;
char e[100],h[100];
int xx;
system("color 3c");
jump:
display_menu();
cin>>s;
switch(s)
case 1:
system("cls");
cin.getline(c,100,'.');
system("cls");
cin.getline(e,100,'.');
system("cls");
cin>>f;
system("cls");
cout<<"Enter Your Phone Number:"<<endl;
cin>>g;
system("cls");
cin.getline(h,100,'.');
system("cls");
jump3:
cin>>h1;
cin>>h2;
if(h1!=h2)
system("cls");
goto jump3;
else if(h1==h2)
system("cls");
sleep(3);
}
jump8:
cin>>h3;
cin>>h4;
if(h3!=h4)
system("cls");
goto jump8;
else if(h3==h4)
sleep(3);
cin>>x;
system("cls");
goto jump;
case 2:
system("cls");
cin>>h5;
xx++;
system("cls");
system("color 2b");
sleep(3);
goto jump;
case 3:
system("cls");
system("color 5a");
sleep(3);
xx++;
goto jump;
case 4:
jump1:
cin>>h6;
if(h6>h5)
system("cls");
goto jump1;
}
system("cls");
h5=h5-h6;
system("color 5e");
xx++;
sleep(3);
goto jump;
case 5:
system("cls");
jump2:
cin>>w;
cin>>h7;
if(h7>h5)
system("cls");
goto jump2;
system("cls");
h5=h5-h7;
system("Color 6f");
xx++;
sleep(3);
goto jump;
case 6:
system("cls");
jump4:
cin>>x1;
cin>>x2;
if(x1!=x2)
system("cls");
goto jump4;
}
else if(x1==x2)
system("cls");
system("color 3c");
sleep(3);
goto jump;
case 7:
system("cls");
jump5:
cin>>h8;
if(h8!=h2)
system("cls");
goto jump5;
jump7:
system("cls");
cout<<"Enter New Password"<<endl;
cin>>x3;
cin>>x4;
if(x3!=x4)
system("cls");
system("color 2a");
goto jump7;
system("cls");
sleep(3);
goto jump;
case 8:
system("cls");
jump9:
cin>>h10;
if(h10>h5)
{
system("cls");
system("color d9");
goto jump9;
system("cls");
h5=h5-h10;
xx++;
sleep(3);
goto jump;
case 9:
system("cls");
jump10:
cout<<" You can Also Pay your Gas Bills Now "<<endl;
cin>>h11;
if(h11>h5)
system("cls");
goto jump10;
system("cls");
h5=h5-h11;
system("color 2b");
goto jump;
case 10:
case 11:
system("color 2b");
sleep(5);
goto jump;
case 12:
system("cls");
system("color 5e");
break;
return 0;
//operatoroverloading
#include<iostream>
using namespace std;
class dig
{
private:
int val;
int val1;
public:
dig()
{
val=0;
}
void input()
{
cout<<"Enter 1 Digit:"<<endl;
cin>>val;
}
void display()
{
cout<<"Answer is:"<<val<<endl;
}
bool operator != (dig b1)
{
if(val==b1.val)
{
return false;
}
else
{
return true;
}
}
dig operator ^ (dig b)
{
dig c;
int i=0;
int total=1;
for(int i=0;i<b.val;i++)
{
total=val*total;
}
c.val=total;
return c;
}
dig operator %(dig b)
{
dig c;
c.val=val%b.val;
return c;
}
dig operator +=(dig b)
{
val=val+b.val;
dig c;
c.val=val;
return c;
}
dig operator *=(dig b)
{
val=val*b.val;
dig c;
c.val=val;
return c;
}
bool operator &&(dig c)
{
if(val%2==0 && c.val%2==0)
{
return true;
}
else
{
return false;
}
}
bool operator || (dig c)
{
if(val%2==0 || c.val%2==0)
{
return true;
}
else
{
return false;
}
}
};
class ar
{
private:
int g[1];
public:
ar operator [](int c)
{
ar t;
cout<<"Enter a Value:"<<endl;
cin>>t.g[c];
return t;
}
void disply()
{
for(int i=0;i<1;i++)
{
cout<<g[i];
}
}
};
int main()
{
dig b,b1,c,d,e,f;
b.input();
b1.input();
cout<<endl;
cout<<"!="<<endl;
if(b!=b1)
{
system("color 2b");
std::cout<<"Values are not Equal."<<endl;
}
else
{
cout<<"Values are Equal."<<endl;
}
system("color 5e");
std::cout<<endl;
cout<<"^"<<endl;
c=b^b1;
c.display();
cout<<endl;
cout<<"%"<<endl;
d=b%b1;
d.display();
cout<<endl;
cout<<"+="<<endl;
b+=b1;
b.display();
cout<<endl;
cout<<"*="<<endl;
b*=b1;
b.display();
cout<<endl;
cout<<endl;
cout<<"&&"<<endl;
if(b&&b1)
{
cout<<"Divisible by 2."<<endl;
}
else
{
cout<<"Not Divisible by 2."<<endl;
}
cout<<endl;
cout<<endl;
cout<<"||"<<endl;
if(b||b1)
{
cout<<"One Value Divisible by 2."<<endl;
}
else
{
cout<<"Not Divisible by 2."<<endl;
}
cout<<endl;
cout<<"[]"<<endl;
ar y;
y=y[0];
y.disply();
cout<<endl;
system("pause");
return 0;
}