Question: Java Problem: Write a collection of while-loops that solve the following problems. The steps for the first problem have been given to you: 1. Prompt
Java Problem:
Write a collection of while-loops that solve the following problems. The steps for the first problem have been given to you:
1. Prompt the user to enter a positive integer n. (You could use Scanner or JOptionPane) Print out all positive integers from 1 to n.
For example: 1 2 3 4 5 ... n
- Use the following steps to solve this problem:
- Prompt the user to enter a positive integer, then store the result in an integer variable named n
- Declare an int variable called count
- Write a while loop that uses your count variable to loop from 1 to n (what should your condition be?)
- Print out count in your loop
2. Write a while loop that calculates and prints the sum of the first 10 positive integers.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
