Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Design a program that will ask the user to input two integer numbers and then perform the basic arithmetic operations such as addition and subtraction

Design a program that will ask the user to input two integer numbers and then perform the basic arithmetic operations such as addition and subtraction

Computer Science

Design a program that will ask the user to input two integer numbers and then perform the basic arithmetic operations such as addition and subtraction. Each calculation is done by a separate function. The main function gets the input from the user, then calls the addition function and the subtraction function one at a time to perform the calculations. Each calculation function (addition or subtraction function) performs an arithmetic operation and then returns the calculation results back to where it was called. The main function then calls the display function to display the results for the user on the screen. Note, the display function is already developed for you. For each set of numbers the user entered, the program produces the sum and the difference of the values. You may assume the difference is calculated by the first number subtracts the second number that the result may yield a negative number. 
Draw an IPO chart and a Pseudocode program for each function . Besides, apply all the techniques you've learned, be sure to document your programs and apply good programming styles. 


I want to ask if I need to declare additional variables to hold the 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 two numbers"


 // 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 in here?
 Set total2 = display() ---- I don't know if I need a variable in here?
  
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 subtraction modules.

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE