Question: Write a small piece of code that prompts the user for a number and adds up the even numbers from 1 to that entered number
Write a small piece of code that prompts the user for a number and adds up the even
numbers from to that entered number using a while loop. You may not use for loops
for this assignment.
Enter the number to add the even numbers up to:
LOOP total
Write another small piece of code that prompts the user for numbers and adds up the
numbers between and including the numbers using a while loop. You may not use
for loops for this assignment. Add all the numbers, not just the even or odd ones.
Enter a lower and upper number to sum:
LOOP total
Write another small piece of code that prompts the user for a file name and adds up all of
the numbers in the file using a while loop. Read until EOF end of file
Enter a file name to read from: inin
LOOP total
Write another while loop around the code for # that prompts the user whether she or he
wants to prompt and read another file.
Enter a file name to read from: inin
LOOP total
Do you want to do all of this again? y
Enter a file name to read from: inin
LOOP total
Do you want to do all of this again? y
Enter a file name to read from: in
error opening file!
Write another while loop that prompts the user for file name and reads & adds up the first
numbers in the file. Part executes even when the error message is printed in Part
For Part you should use a break statement inside the if instead of doing a return
when the file doesn't open.
Enter another file name to add numbers from: inin
LOOP total
Finally, add to Part # a while loop to print the nd number in the file.
Enter another file name to add numbers from: inin
second number
LOOP total
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
