Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 valueStep 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