Results 1 to 2 of 2
  1. #1
    akiraaisha is offline Member
    Join Date
    Aug 2014
    Posts
    3
    Rep Power
    0

    Exclamation Need help in my code. :(

    This is my Code:
    Java Code:
    import static java.lang.System.out;
    import java.util.Scanner;
    public class KmToMile {
    	public static void main(String []args) {
    		int x;
    		Scanner in = new Scanner (System.in);
    		out.print("Please enter a number to convert KM to Mile: ");
    		x = in.nextInt();
    		int[] y = new int [x];
    		double z = 0.621371;
    		out.println("Kilometer to Mile: " + x * z);
    		
    		
    }
    }
    I want to make a kinda looping like "Do u want to try another?" then he say yes, then it will loop to "Please enter a number to convert KM to Mile: " it has to be infinite request.
    Sorry for my bad english.
    Last edited by akiraaisha; 08-13-2014 at 10:39 AM.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: Need help in my code. :(

    So? You know you have to use a loop, so go investigate how to use loops.

    Once you have it looping back to the beginning, then add the yes/no question and you're done.


    PS: you will probably get into the situation where you have an application which will not ever stop because it will just keep on looping forever. Press CTRL + C to quit your program.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 16
    Last Post: 01-31-2012, 09:36 PM
  2. Replies: 3
    Last Post: 08-10-2011, 10:17 AM
  3. Replies: 0
    Last Post: 08-07-2011, 09:32 PM
  4. Replies: 0
    Last Post: 02-21-2011, 12:50 PM
  5. Replies: 1
    Last Post: 04-26-2007, 04:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •