1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tresset_1 [31]
3 years ago
4

The variables x and y refer to numbers. Write a code segment that prompts the user for an arithmetic operator and prints the val

ue obtained by applying that operator to x and y.

Computers and Technology
1 answer:
timama [110]3 years ago
8 0

Answer:

Here is the Python program. If you want the program in some other programming language let me know.    

x = int(input("Enter the value of x: "))

y = int(input("Enter the value of y: "))

op = input("Enter an arithmetic operator : ")

operation = 0

if op == '+':

   operation = x + y

elif op == '-':

   operation = x - y

elif op == '*':

   operation = x * y

elif op == '/':

   operation = x / y

elif op == '%':

   operation = x % y

else:

   print("Invalid Character!")

print(x, op , y, "=", operation)

Explanation:

The program prompts the user to enter the value of x and y. These values are stored in variables x and y

Then the program prompts the user to enter an arithmetic operator. op variable stores the value of operator entered by the user.

If else statement is used which checks the the character of operator ( +, - , /,  * or %) that the user inputs and performs the arithmetic operation according to the input operator. The if else part that will be executed to perform the arithmetic operation is based on the operator that the user enters. For example if the user enters / then the third elif part is executed and the value of x and y are divided.

The screen shot of output of the program is attached.

You might be interested in
When was kale discovered?
anyanavicka [17]
Kale was discoverd just 2 years ago ........
8 0
3 years ago
Which of the following is a template definition?
musickatia [10]

Answer:

b. template<classT>.

Explanation:

Template functions are that can work with generic types. Template lets us to create a function so that more than 1 type or class can adapt  the functionality of that function.

We can write the template function as following:-

template<class typename>.

It matches to the option b.

5 0
3 years ago
3. What of the following is the main components of computer system?
Likurg_2 [28]

Answer:

CPU, input unit, Output unit, memory unit

3 0
2 years ago
Read 2 more answers
// This class calculates a waitperson's tip as 15% of the bill public class DebugThree1 { public static void main(String args[])
DENIUS [597]

I added a decimal format to keep all decimals within the hundredths place. I also changed the calcTip method to void and the argument to a double. Void means the method doesn't return anything and changing bill to type double let's us pass numbers with decimals to the calcTip method. I hope this helps!

Download txt
4 0
3 years ago
Dynamic disk storage provides the flexibility to logically organize disk space across one or more disk drives.
zhuklara [117]
<span>Dynamic disk storage provides the flexibility to logically organize disk space across one or more disk drives. 
a. True 
b. False</span>
3 0
3 years ago
Other questions:
  • Dinah is using an I.D.E to write, modify, and save code. Which tool should she use?
    8·2 answers
  • A ____ is a data network connection that makes use of the public telecommunications infrastructure but maintains privacy through
    13·1 answer
  • 1) which colour filter is used to pumps up black and white effects?
    13·1 answer
  • Mobile devices need to work within limited screen space ? true or false
    9·2 answers
  • "What line of code can be used to provide a convenient way to merge the source code from one file with the source code in anothe
    8·1 answer
  • I'm having trouble changing my google account password
    12·1 answer
  • Anyone here play osu! ?
    11·2 answers
  • ASAP BRAINLIEST!!!
    6·1 answer
  • 2. How much did John Jones have in his account on the first day of the
    5·1 answer
  • Polynomial regression A common misconception is that linear regression can only be used to fit a linear relationship. We can fit
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!