public static void main(String[] args) {
//Question 1.
//int[] array = {1,-2,3,0,5,6,7,8,100,10};
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the rate of exchange: ");
double exchange_rate = scanner.nextDouble();
System.out.println("Press 0: to conver Dollar to Turkish Lira \nPress 1: to conver Turkish Lira to Dollar" );
int choice = scanner.nextInt();
if(choice == 0) {
System.out.println("Enter amount in Dollar: ");
double amount = scanner.nextDouble();
amount = amount * exchange_rate;
System.out.printf("Your amount from Dollar to Turkish Lira is %.3f: " , amount , " Lira");
}
else if(choice == 1)
System.out.println("Enter amount in Turkish Lira: ");
double amount = scanner.nextDouble();
amount = amount / exchange_rate;
System.out.printf("Your amount from Turkish Lira to Dollar is %.3f: " , amount , " Dollar");
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter