You will ask the user the type of operation he wants to do. 1- addition, 2-multi
ID: 3558990 • Letter: Y
Question
You will ask the user the type of operation he wants to do. 1- addition, 2-multiplication, 3- comparison, 4- Read names and ages from file for a limited number of times or until the end of file, -1- end of program. You must implement a loop which will end by -1 from user input.
You will have at least 4 modules for 4 tasks. For the comparison task you will ask the user the number of integers to compare. You will find the largest and smallest integer from the input. All input and calculation work will be done inside another module which will be called. Main module will get the operation code(1, 2,3, 4 and -1) and call the corresponding modules(ex: Add(), Multiply(), Compare(), ReadNamesAges()). As you can figure out the type of operation will be inputted in the main program. After checking the type of operation you will call the respective module to get the operation done. You must have at least one module with reference parameter(s). Your output will be saved in a file called
Explanation / Answer
Module Main ( )
//This is the main module that will ask the user what operation they would like to do.
//Declare variables
Declare real operation
Declare real sum
Declare real counter
Declare integer index
Declare integer number
Declare real product
//Declare Function Calls
Call Add(sum, counter, index, num[ ])
Call Multiply(product, counter, index, number)
Call Compare(largest, smallest, index, counter)
Call ReadNamesAges(name, age, MyFile, MyOut)
//Set variables
Set sum = 0
Set index = 0
Set counter = 1
Set product = 1
Set number = 1
//Put all information gained into output file named MyOut.txt
Open MyOut
//Set Loop
// Ask the user the type of operation he wants to do.
Display
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.