Question: Using Java Sum of 50 numbers 4 .Write a program that asks user for a positive integer value. The program should use a loop to
Sum of 50 numbers 4 .Write a program that asks user for a positive integer value. The program should use a loop to get the sum of all integers from 1 up to the number For eg if the user enters 40, it should find the sum of 1 to 40 . Output Enter a positive nonzero number: 40 The sum of all the integers from 1 through 40 is 820 Validation should be done if it is a non negative numbetr Enter a positive nonzero number: -20 Invalid. Enter a positive nonzero number: 20 The sum of all the integers from 1 through 20 is 210
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
