Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started