Design a program that will ask the user to input two integer numbers and then perform...

90.2K

Verified Solution

Question

Programming

Design a program that will ask the user to input two integernumbers and then perform the basic arithmetic operations such asaddition and subtraction. Each calculation is done by a separatefunction. The main function gets the input from the user, thencalls the addition function and the subtraction function one at atime to perform the calculations. Each calculation function(addition or subtraction function) performs an arithmetic operationand then returns the calculation results back to where it wascalled. The main function then calls the display function todisplay the results for the user on the screen. Note, the displayfunction is already developed for you. For each set of numbers theuser entered, the program produces the sum and the difference ofthe values. You may assume the difference is calculated by thefirst number subtracts the second number that the result may yielda negative number.

Draw an IPO chart and a Pseudocode program for each function .Besides, apply all the techniques you've learned, be sure todocument your programs and apply good programming styles.

I want to ask if I need to declare additional variables to holdthe arguments being sent to the display function.

Function void main()

// Declare the Variables.

  

Declare integer num1, num2, total, total2

  

// Display Greeting message.

  

Display \"Input two integer numbers.\"

Display \"And I will tell you the sum and difference of the twonumbers\"

// Prompt User for the first number.

  

Display \"Enter the first number: \"

Input num1

  

// Prompt User for the second number.

  

Display \"Enter the second number: \"

input num2

  

// Get the sum of both numbers.

  

Set total = addition(num1, num2)

  

// Get the difference of both numbers.

  

Set total2 = subtraction(num1, num2)

// Send the results to the display function.

  

Set total = display() ---- I don't know if i need a variable inhere?

Set total2 = display() ---- I don't know if I need a variable inhere?

  

End Function

Function void display(Integer arg1, Integer arg2)

  // Display the sum.

  Display \"The sum is\",arg1

  

  Display the difference.

  Display \"The difference is\",arg2

End Function

P.S: I have already done the addition and subtractionmodules.

Answer & Explanation Solved by verified expert
4.1 Ratings (777 Votes)
After calculating sum and Difference call displayfunction by passing total and total2 as function argument no needto declare any additional variable to hold argument of displayfunctionplease refer to the corrected Pseudo code belowFunction void main Declare the Variables Declare integer num1 num2 total total2 Display Greeting message Display Input two integer numbersDisplay And I will tell you the sum    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students