Question: CSE 2133 - Lab 1 Part A You will write an interactive program (name it lab1a.cob ) that will prompt the user for a 4
CSE 2133 - Lab 1
Part A
You will write an interactive program (name it lab1a.cob) that will prompt the user for a 4 digit (unsigned) number. The program will repeat this until the user enters a 0. Once a 0 is entered by the user the program will stop executing; this program only performs a single session.
When the user enters a 0, the program will show the number of items entered. Note that the 0 is not to be treated as an entered number; it is strictly a sentinel value, not data. Make sure all instructions and outputs are clear and meaningful.
Sample session:
Enter a 4-digit unsigned number (0 to stop): 12
Enter a 4-digit unsigned number (0 to stop): 8
Enter a 4-digit unsigned number (0 to stop): 9999
Enter a 4-digit unsigned number (0 to stop): 5
Enter a 4-digit unsigned number (0 to stop): 270
Enter a 4-digit unsigned number (0 to stop): 1
Enter a 4-digit unsigned number (0 to stop): 9876
Enter a 4-digit unsigned number (0 to stop): 0
The number of values entered: 0007
Part B
This will be a modification of lab1a. This program will be named lab1b.cob and will allow for multiple sessions in a run.
The program will ask the user if there is to be another session. An input of N to this prompt will stop the program. Any other input value can be treated as if it was a Y and will cause the program to initiate a new session identical to that in part A above. Once the session ends, it will then ask the user if there is to be another session.
Sample run:
Another Session (Y/N)? Y
Enter a 4-digit unsigned number (0 to stop): 12
Enter a 4-digit unsigned number (0 to stop): 8
Enter a 4-digit unsigned number (0 to stop): 9999
Enter a 4-digit unsigned number (0 to stop): 5
Enter a 4-digit unsigned number (0 to stop): 270
Enter a 4-digit unsigned number (0 to stop): 1
Enter a 4-digit unsigned number (0 to stop): 9876
Enter a 4-digit unsigned number (0 to stop): 0
The number of values entered: 0007
Another Session (Y/N)? Y
Enter a 4-digit unsigned number (0 to stop): 18
Enter a 4-digit unsigned number (0 to stop): 19
Enter a 4-digit unsigned number (0 to stop): 20
Enter a 4-digit unsigned number (0 to stop): 0
The number of values entered: 0003
Another Session (Y/N)? N
Part C
This will be a modification of lab1a. This program will be named lab1c.cob and will be a batch version of lab1a.cob. The input file will be named lab1c-in.dat and will be located in the same directory as the lab1c executable (so do not specify a path for the file in the Select statement). Each record of the file will contain a single 4-digit unsigned number. This program will display to the screen the number of items in the file.
There is no sentinel value within the file; each record is to be treated as data, even if the value on the record is 0. Also, each file represents a single session.
Bonus Points
Bonus points are possible for each of the three parts if the programs can also show how many even numbers were entered in the session for each session. Note that 0 is not to be treated as an entered number; it is strictly a sentinel value, not data.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
