Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class CurrencyConversion
- {
- public static void main(String args[])
- {
- /*Initalizing the required variables*/
- float rup,dol,ans;
- int ch=0;
- Scanner sc=new Scanner(System.in); //Scanner object to get input from user
- while(ch!=3) //while loop to run the program in repeating mode
- {
- System.out.print("\n1. Convert rupees to dollar. \n2. Convert dollar to rupees.\n3. Exit");
- System.out.print("\nEnter your choice: ");
- ch=sc.nextInt();
- switch(ch)
- {
- case 1: //Case 1 to conver rupees into dollar
- System.out.print("Enter the amount in rupees: ");
- rup=sc.nextFloat();
- ans=rup/60;
- System.out.print("Amount in dollar: "+ans+"\n");
- break;
- case 2: //Case 2 to convert dollar into rupees
- System.out.print("Enter the amount in dollar: ");
- dol=sc.nextFloat();
- ans=dol*60;
- System.out.print("Amount in rupees: "+ans+"\n");
- break;
- case 3: //Case 3 to exit from the program
- break;
- default:
- System.out.print("Enter the correct choice...."+"\n");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment