Write a simple calculator program. Your program should accept as input an expression in the form of: 3 * 2 Use an if / elif ladder style structure to determine what operation needs to be performed on the two numbers. Your program should handle the arithmetic functions Add, Subtract, Multiply, and Divide (Depending on the operator entered). Input: For this assignment you are going to want to take in a string that has the expression separated by a space. Once you have stored the string you will need to split it. This means to get each individual part of the expression. Python has a split function that is part of the string. It will return a list of the pieces that were split. I realize we haven't discussed lists yet so I will give you some code. Suppose you have the expression: str

Answers

Answer 1

Answer: Provided in the explanation section

Explanation:

provided below is the program to carry out this task, i hope it provides clarity.

#include <iostream>

using namespace std;

int main() {

  int n1, n2;

  char ch;

  cout << "Enter an expression" << endl;

  cin >> n1 >> ch >> n2;

  switch(ch) {

      case '+':

          cout << "The sum is " << n1+n2 << endl;

          break;

      case '-':

          cout << "The difference is " << n1-n2 << endl;

          break;

      case '*':

          cout << "The product is " << n1*n2 << endl;

          break;

      case '/':

          cout << "The division is " << n1/n2 << endl;

          break;

      default:

          cout << "Invalid expression" << endl;

  }

  return 0;

cheers  i hope this helped !!

}


Related Questions

If i wanted to change my phones simcard, does anything need transferring, or is it an easy swap?

Answers

Most likely not but I think you’ll have to log in your account like if you have an Apple phone . You’ll have to log into your Apple ID
Other Questions
Read the passage. Delia pointed out the slender branches of the almond tree to Kaveh, noting the flowers that were about to bloom. As they walked through the garden, Kaveh noticed a skinny tree in the corner of the yard and asked Delia what type it was. How does the word choice slender affect the meaning of the passage? The word slender implies that the almond tree is elegant. The word slender implies that the almond tree is not growing very well. The word slender implies that the almond tree is underfed. The word slender implies that the almond tree is natural. define hardware.Give 2 examples A student walk 60m on a bearingof 028 degree and then 180mdue east. How is she from herstarting point, correct to thenearest whole number? Question 9 (5 points)In Joy Luck Club, which of the following choices best explains why the beautyinstructor tells the narrator and her mother that "Peter Pan is very popular thesedays" in Paragraph 8? whats the solution of y=x-4 and y=1/3x what is ud. form of the verb dormir in the preterite tense a. durmieron b. dormiste c. duerme d. durmio Please describe the regulation of the blood glucose 6 hours after a meal?Please include all relevant organs, hormones, and actions. 2 less than a number times 6 During World War I, Japan demonstrated its growing power by:A. using its large navy to capture German colonies in the Pacific andIndian oceans.B. convincing China and Korea to join it in a military alliance againstGermany.C. providing food and military equipment to the United Statesthroughout the war.D. sending troops to Europe to help end the stalemate on theWestern Front.SUBMIT The top figure in the composite figure is called a . And What is the volume? Can someone please help me with this I dont get it please help me James earns $1000 weekly base pay as a sales-person and gets a 10% commission on everything he sells. It is said that he sold $20,000 worth of merchandise last month, how much did he earn for the month? Provide an explanation :)) A. $4,000 B. $22,000 C. $6,000 D. $2,000 How is this picture an oxymoron The Pyrenees mountain range isabout how many feet up inElevation? Leleti believes that her friend spilled soda all over her backpack in order to get revenge for a remark Leleti made a few days ago, even though her friend claims that the incident was an accident. Leleti is making a: Which term best describes the temperature and weather conditions of an organisms environment? Could the fighting over slavery have been peacefully resolved? What is the net ionic equation of the reaction of MgSO4 with Ba(NO3)2 ? Solve for x. 9x-2c=k What does Lincoln wish to do through this finalsentence of the speech?With malice toward none, with charity for all, withfirmness in the right as God gives us to see the right, letus strive on to finish the work we are in, to bind up thenation's wounds, to care for him who shall have borne thebattle and for his widow and his orphan, to do all whichmay achieve and cherish a just and lasting peace amongourselves and with all nations.-Second inaugural address,Abraham Lincolnleave the listener feeling sad and hopelesscause the listener to feel angry about the length ofthe unwinnable warstir up emotions about the lives lost in the war andencourage the listener to help end itmake the listener blame the South for the ongoingviolence