Write a Java program that uses one for for-loop to compute the sum of even numbers as well as the sum of odd numbers between 1-100 and print out results. Use 2 variables to store your results.
Added by Catherine C.
Close
Step 1
We need to declare two variables to store the sum of even numbers and the sum of odd numbers. Let's call them evenSum and oddSum and initialize them to 0. Show more…
Show all steps
Your feedback will help us improve your experience
Emily Himsel and 60 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Write a program to input a number and print the sum of its even digits and odd digits separately. (In BlueJ)
Sarvesh S.
write a program in java to input values from user till the time an even number not entered and then find the sum of all odd values
Supreeta N.
'IN JAVA , write program to print sum of first 100 even natural numbers'
Cora M.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
100,000+
Students learning Computer Science with Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD