#include<iostream.h>
#include<conio.h>
class planets
{
static float g;
float w,m;
int ch;
public:
void accept()
{
cout<<"Find weight on:"<<endl;
cout<<"1:MERCURY\n2:VENUS\n3:EARTH\n4:MARS\n5:JUPITER\n6:SATURN\n7:URANUS\n8:NEPTUNE"<<endl;
cout<<"Enter your choice:"<<endl;
cin>>ch;
switch(ch)
{
case 1:
g=3.61;
break;
case 2:
g=8.83;
break;
case 3:
g=9.8;
break;
case 4:
g=3.75;
break;
case 5:
g=26.0;
break;
case 6:
g=11.2;
break;
case 7:
g=10.5;
break;
case 8:
g=13.3;
break;
}
cout<<"Enter mass:";
cin>>m;
}
void display()
{
w=m*g;
cout<<"Weight="<<w;
}
};
float planets::g;
void main()
{
clrscr();
planets p;
p.accept();
p.display();
getch();
}
/*Output:
Find weight on:
1:MERCURY
2:VENUS
3:EARTH
4:MARS
5:JUPITER
6:SATURN
7:URANUS
8:NEPTUNE
Enter your choice:
3
Enter mass:10
Weight=98 */
#include<conio.h>
class planets
{
static float g;
float w,m;
int ch;
public:
void accept()
{
cout<<"Find weight on:"<<endl;
cout<<"1:MERCURY\n2:VENUS\n3:EARTH\n4:MARS\n5:JUPITER\n6:SATURN\n7:URANUS\n8:NEPTUNE"<<endl;
cout<<"Enter your choice:"<<endl;
cin>>ch;
switch(ch)
{
case 1:
g=3.61;
break;
case 2:
g=8.83;
break;
case 3:
g=9.8;
break;
case 4:
g=3.75;
break;
case 5:
g=26.0;
break;
case 6:
g=11.2;
break;
case 7:
g=10.5;
break;
case 8:
g=13.3;
break;
}
cout<<"Enter mass:";
cin>>m;
}
void display()
{
w=m*g;
cout<<"Weight="<<w;
}
};
float planets::g;
void main()
{
clrscr();
planets p;
p.accept();
p.display();
getch();
}
/*Output:
Find weight on:
1:MERCURY
2:VENUS
3:EARTH
4:MARS
5:JUPITER
6:SATURN
7:URANUS
8:NEPTUNE
Enter your choice:
3
Enter mass:10
Weight=98 */
No comments:
Post a Comment