Question: Fix the code. To create scanner to ask the user to enter number and automatically convert them and ask if you want to continue or
Fix the code. To create scanner to ask the user to enter number and automatically convert them and ask if you want to continue or you want to exit.
import java.util.Scanner;
public class ArgumentDemo1 { public static void main(String[]args) { double miles; Scanner Keyboard= new Scanner(System.in); miles= Keyboard.nextDouble(); showKilometers( miles); } public static void showKilometers(double miles) {
while(miles>0) { for(int i=0; i<6;i++) { double Kilometers = miles *1.609; System.out.println(miles + " miles is equal to " + Kilometers + "kilometers"); } } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
