Question: In Java Write a program that asks the user for a positive nonzero integer value which is stored in variable N. (Input Validation: keep asking

In Java Write a program that asks the user for a positiveIn Java

Write a program that asks the user for a positive nonzero integer value which is stored in variable N. (Input Validation: keep asking the user until he enters a valid one). With a valid input, do the following using separate loops. The program should use a For Loop to get the sum of all the integers from 1 up to N and finally calculate the average. For example: if the user enters 10, the loop will find the sum of 1,2,3,4...10 and then compute the average. In another For Loop, compute the sum of all even numbers and odd numbers in from 1 up to N and also calculate the averages of even set and odd set. For example, if N is 10, sum Even is sum of 2,4,6...10 and average Even is its average value. Sum Odd is sum of 1,3,5...9 and average Odd is its average value

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!