Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Using Java
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions