Answer to Question #3523 in Java | JSP | JSF for Y mukundareddy
4) Write a program to print n umbers and enter a number where you want to break the program
1
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!
Learn more about our help with Assignments:
JavaJSPJSF
Comments
Leave a comment