Write a program that reads from the user an integer and prints it until the user enters 0

Showing Answers 1 - 2 of 2 Answers

Himu

  • Dec 5th, 2014
 

Code
  1. import java.util.Scanner;

  2. public class test {

  3.         public static void main(String[] args) {

  4.             int f=1;

  5.             System.out.println("Enter any number. Press 0 to exit....");

  6.                 do{

  7.                         Scanner in = new Scanner(System.in);

  8.                     f = in.nextInt();

  9.                     System.out.println(f);

  10.                 }while(f!=0);

  11.                 System.out.println("End of program");

  12.         }

  13. }

  14.  

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions