Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CST 2 2 2 Instruction: Write a console program that: Uses a while loop to perform the following steps: 1 . Prompt the user to
CST Instruction:
Write a console program that:
Uses a while loop to perform the following steps:
Prompt the user to input two integers: firstNum and secondNum where secondNum is at least greater than firstNum, both numbers are positive integers, and secondNum is less than
Verify that the user entered acceptable numbers, and if not, provide error feedback and prompt them again.
Output all results to a file in the same directory as the program, placing an appropriate label between each section of output. Note that your program must be able to run repeatedly overwriting the file from the previous run.
Output all odd numbers between firstNum and secondNum inclusive, one number per line.
Output the sum of all numbers between firstNum and secondNum exclusive.
Uses a for loop to perform the following steps:
Continue writing to the same file as before.
Write a label as before.
Output all numbers from secondNum to firstNum in a single line with commas separating the numbers.
Write the date and time as the last line in the file in the format yyyy mm dd hh:mm:ss
Notes:
Inclusive means that the firstNum and secondNum are output if appropriate.
Exclusive means that the firstNum and secondNum are not output.
The instructor will attempt to crash your program by entering numbers you don't expect if you program throws an exception you will be marked down!
Step 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