Wednesday, October 30, 2013

2.07 - Repeat until 0 do while

/*
 * Autor: Juan Antonio Ripoll
 * Date: 30/10/13
 * 
 * Create a JAVA program to ask the user for a number "x" and display 10*x. 
 * It must repeat until the user enters 0 (using "do-while"). 
 * */

import java.util.Scanner;

public class Main {

 public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  
  int number;
     do
     {
      System.out.print("Enter a number: ");
         number = in.nextInt();
         
      System.out.println(number*10); 
     }
     while (number != 0);
 }
}

No comments:

Post a Comment