Create a JAVA program to display the numbers 1-10. Although you could program a solution that has ten lines of code like the following, think about why this would be a bad idea when developing a programming solution:
Print 1
Print 2
Print 3
Print 4 (continued to Print 10)
Note: Examples for Java programs (Loop and no loop) programs are in the "Important Documents" folder / Module 6.
Java Program:
public class Main
{
public static void main(String[] args) {
for (int i=1; i<=10; i++)
{
System.out.println("Print " + i);
}
}
}
Output:
Loop increases your time complexity as well as affect your system timeline cost. Because it can't be terminated until the given condition. Time complexity increases risks and it requires more testing repeatedly. That's would be a bad idea when developing a programming solution.
Thumbs Up Please !!!
Get Answers For Free
Most questions answered within 1 hours.