![pepehammu](/avatars/19277.jpg)
pepehammu
14.12.2019 •
Computers and Technology
Write a simple arithmetic expression translator that reads in expressions such as 25.5 + 34.2 and displays their value. each expression has two numbers separated by an arithmetic operator. (hint: use a switch statement with the operator symbol (type char) as a selector to determine which arithmetic operation to perform on the two numbers. for a sentinel, enter an expression with zero for both operands.)
Solved
Show answers
More tips
- C Computers and Internet Dropbox: What is it and How to Use it...
- H Health and Medicine How to Increase Hemoglobin in the Blood...
- A Animals and plants How to Store Carrots: Tips for Homeowners...
- L Legal consultation Juvenile Justice: Who Needs It?...
- F Family and Home How to Choose the Best Diapers for Your Baby?...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
- T Travel and tourism Maldives Adventures: What is the Best Season to Visit the Luxurious Beaches?...
- H Health and Medicine Kinesiology: What is it and How Does it Work?...
Answers on questions: Computers and Technology
- B Biology The mass of an object multiplied be it s speed is?...
- M Mathematics Cj has $50 more than Jordan has. Together they have $100. How much does Jordan have?...
- M Mathematics The 5 fourth-grade classes at brown elementary raised a total of $2,462 to purchase playground equipment. write and solve an equation that shows one way to estimate the...
- B Business Consider the following model of a very simple economy. household saving and investment behavior depend in part on wealth (accumulated savings and inheritance). in the late...
Ответ:
Following are the program in the C++ Programming Language.
//header file
#include<iostream>
//header file
#include <bits/stdc++.h>
//namespace
using namespace std;
//set main function
int main()
{
//set float type variables
float a,s,m,d,c,b,g;
//print message and get variable from the user
cout<<" Enter The First Number : ";
cin>>c;
//print message and get variable from the user
cout<<" Enter The Second Number: ";
cin>>b;
again:
//get variable from the user for Operation
cout<<" Enter the Operation which you want : ";
char choice;
cin>>choice;
//Addition
a=c+b;
//Subtraction
s=c-b;
//Multiplication
m=c*b;
//Division
d=c/b;
//Modulus
g=fmod(c, b);
//set switch statement
//here is the solution
switch(choice)
{
case '+':
cout<<"Addition: "<<a<<endl;
goto again;
break;
case '-':
cout<<"Subtraction: "<<s<<endl;
goto again;
break;
case '*':
cout<<"Multiplication: "<<m<<endl;
goto again;
break;
case '/':
cout<<"Division: "<<d<<endl;
goto again;
break;
case '%':
cout<<"Modulus: "<<g<<endl;
goto again;
break;
default:
cout<<"Exit";
break;
}
return 0;
}Explanation:
Here, we define the required header files then, we set main function.
set float type variables a,s,m,d,c,b,g.Get input from the user for operation in the variable c,d.Set character type variables in which we get input from the user for operations.Then, we perform some operations.Set switch statement which display the output according to the user an if user input wrong then statement breaks.Ответ:
I think the best answer is B.
Explanation:
I am not complely sure, sorry.
Hope it helps though!!