Answer to Question #3523 in Java | JSP | JSF for Y mukundareddy

Question #3523
4) Write a program to print n umbers and enter a number where you want to break the program
1
Expert's answer
2012-03-06T10:30:56-0500
import java.util.Scanner;




public class Main {




public static void main(String[] args) {




int n;

Scanner in = new Scanner(System.in);

System.out.print("Enter a number where you want to break the program: ");

n = in.nextInt();

if(n > 0){

for(int i = 1; i < n+1; i++){

System.out.println(i);

}

}

else

System.out.println("ERROR");

}




}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS