Question: Write a for loop that reads an integer from the user, and prints the sum of numbers from 1 to that integer (inclusive). If the

Write a for loop that reads an integer from the user, and prints the sum of numbers from 1 to that integer (inclusive). If the user enters a number less than 1, he/she should be prompted to enter a number greater or equal to 1. In java

Sample input:

Enter an integer greater or equal to 1: 0

Wrong input!

Enter an integer greater or equal to 1: 2

Sample output:

The sum of integers from 1 to 2 is 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!