60 377
Assignments Done
98,1%
Successfully Done
In April 2018

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

Question #3495
1. Write a program to print n umbers and break the program when n==10.
Expert's answer
import java.util.Random;


public class BreakWhen10
{
public static void main(String[] args)
{
Random generator = new Random(100);
int n = generator.nextInt(20) + 10;
System.out.println("The total amount of numbers (n) = " + n);
for (int i = 0; i < n; i++)
{
System.out.print(i + " ");
if (i == 10)
break;
}
}
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions