Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

update below code (Currency conversion program) to add loop. (Implement if/else ladder for menu control) Please tell me how to add loop(while) into the code

 update below code (Currency conversion program) to add loop. (Implement if/else ladder for menu control)

Please tell me how to add loop(while) into the code


1) If the user enters an invalid input the program loop back and allow the user to re-enter input until user input is valid

2) if the user input in the menu is invalid allow the user to re-enter input until user input is valid

*********************************************************************

  1. User Input dollar amount
  2. verify dollar amount
  3. open menu
  4. receive user menu selection
  5. output if menu is correct
  6. loopback to allow the user to make menu until correct

********************************************************************

image

import java.util.*; public class CurrencyConversion_loop { public static void main(String arg[]) { //Creates an object of Scanner Scanner sc = new Scanner(System.in); System.out.println("Enter 1. Euro Conversion"); System.out.println("Enter 2. Yen Conversion"); System.out.println("Enter 3. Peso Conversion"); System.out.println("Enter 4. Bitcoin Conversion"); System.out.println("Enter 5. All Conversion"); //takes selection's numebr from user System.out.println("Select the number: "); int datal sc.nextInt(); // takes input from user, the funds in dollar System.out.println("Enter funds in dolloar"); double dollars = sc.nextDouble(); double euro = dollars*0.92; double yen dollars*126.65; double peso dollars 19.97; double bitcoin dollars*0.000025; //Varifying the value that user entered. if(datal 1){ } " System.out.println(dollars + "dollars = " + euro + EUROS"); else if(data1 == 2){ } System.out.println(dollars + "dollars = else if(data1 == 3) { } System.out.println(dollars + "dollars = else if(data1 == 4){ } System.out.println(dollars + "dollars = else if(data1 == 5){ System.out.println(dollars + "dollars = System.out.println(dollars + "dollars = System.out.println(dollars + "dollars = System.out.println(dollars + "dollars = " " + yen + YENS"); " + peso + PESOS"); + bitcoin + " BTCS"); " + euro + EUROS"); + yen + "YENS"); + peso + " PESOS"); + bitcoin + " BTCS"); } else { System.out.println("Invalid Input"); sc.close(); } } 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To add a loop to the currency conversion program and implement menu control using an ifelse ladder y... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Research An Applied Orientation

Authors: Naresh K Malhotra

6th edition

136085431, 978-0136085430

More Books

Students also viewed these Programming questions

Question

Disordered eating in dance professionals

Answered: 1 week ago

Question

5.7 Describe the role of cultural code frame switching.

Answered: 1 week ago