In C++ program 👇 #include<iostream.h>
#include<conio.h>
void main()
{
int ch;
float in,cm,fh,cl;
while(ch!=0)
{
clrscr();
cout<<"Converst";
cout<<"\n\t1. Inch to Centimetre";
cout<<"\n\t2. Centimetre to Inch";
cout<<"\n\t3. Celsius to Fahrenheit";
cout<<"\n\t3. Celsius to Fahrenheit";
cout<<"\n\n\t\tChoose any converstion:";
cin>>ch;
switch(ch)
{
case 1:
cout<<"\nEnter Inch:";
cin>>in;
float c=in*2.54;
cout<<"Centimetre:"<<c;
break;
case 2:
cout<<"\nEnter Centimetre:";
cin>>cm;
float i=cm/0.394;
cout<<"Inch is:"<<i;
break;
case 3:
cout<<"\nEnter Fahrenheit:";
cin>>fh;
float ce=(fh-32)+5/9;
cout<<"Celsius is:"<<ce;
break;
case 4:
cout<<"\nEnter Celsius:";
cin>>cl;
float f=(cl*9/5+32);
cout<<"fahrenheit is:"<<f;
break;
default:
cout<<"noting";
break;
}
getch();
}}
java source code
import java.util.Scanner;
class conv
{
public static void main(String[] agrs)
{
int ch;
float cm,in,fa,cel;
while(true)
{
System.out.println(" 1. Inch convert to Centimetre" );
System.out.println(" 2. Centimetre convert to Inch " );
System.out.println(" 3. Celcius convert to Fahrennheit" );
System.out.println(" 4. Fahrennheit convert toCelcius" );
System.out.println(" Choose any Opertion" );
Scanner k=new Scanner (System.in);
ch=k.nextInt( );
switch(ch)
{
case 1:
System.out.println(" Enter Inch " );
in=k.nextFloat( );
double ctm=(in*2.54);
System.out.println(" Centimetre " +ctm);
break;
case 2:
System.out.println(" Enter Centimetre" );
cm=k.nextFloat( );
double inc=(cm*0.39);
System.out.println(" Inch is:" +inc);
break;
case 3:
System.out.println(" Enter Celsius " );
cel=k.nextFloat( );
float f=(cel*9/5+32);
System.out.println(" Fahrenhet is " +f);
break;
case 4:
System.out.println(" Enter Fahrenhet: " );
fa=k.nextFloat();
float cels=(fa-32)+5/9;
System.out.println(" Celsius is " +cels);
break;
default:
if(ch==0)
{
System.exit(0);
}
System.out.println(" Nothing,Please try again!" );
System.out.println(" " );
System.out.println(" " );
}
}
}
}
No comments:
Post a Comment