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
Write a procedural programming loop.. Your loop should start variable n with a value of 10 and count down to zero. The loop shou
anastassius [24]

Answer:

//Here is the for loop in C.

for(n=10;n>0;n--)

{

   printf("count =%d \n",n);

}

Explanation:

Since C is a procedural programming language.Here if a loop that starts with n=10; It will run till n becomes 0. When n reaches to 0 then loop terminates otherwise it  print the count of n.

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{  // variables

int n;

// for loop that runs 10 times

// when n==0 then loop terminates

for(n=10;n>0;n--)

{

   cout<<"count ="<<n<<endl;

}

return 0;

}

Output:

count =10

count =9

count =8

count =7

count =6

count =5

count =4

count =3

count =2

count =1

3 0
3 years ago
A department manager would like to choose an access control model in which the owner of a resource decides who may modify permis
Hoochie [10]

Answer: Discretionary access control (DAC)

Explanation: Discretionary access control is the control system that is imposed over the information system. The information systems contains different objects and subjects that gets the permission to do the operations.

The operation which the components can do are sharing the data to other object or subjects, privilege providence, change in the rules for the access, security entities getting changed etc.

4 0
3 years ago
Given the list of customer segments below please create a new list of the names of the segments only using(a) a for loop(b) a li
Alchen [17]

Answer:

new_segment = [ ]

for segment in segments:

   new_segment.append({'name': segment, 'average_spend': money})

print( new_segment)

Using list comprehension:

new_segment =[{'name': segment, 'average_spend': money}  for segment in segments]

Using map():

def listing(a):

   contain =  {'name': segment, 'average_spend': money}

   return contain

new_segment = [ ]

new_segment.append(map( listing, segment))

print(list(new_segment)

Explanation:

The python codes above create a list of dictionaries in all instances using for loop, for loop in list comprehension and the map function which collect two arguments .

7 0
3 years ago
Suppose you are provided with 2 strings to your program. Your task is to join the strings together so you get a single string wi
Mariulka [41]

Answer:

public class TestImport{

   public static void main(String[] args) {

       String string1 = args[1];

       String string2 = args[2];

       System.out.println(string1 +" " +string2);

   }

}

Explanation:

The solution here is to use string concatenation as has been used in this statement System.out.println(string1 +" " +string2);

When this code is run from the command line and passed atleast three command line arguments for index 0,1,2 respectively, the print statment will return the second string (that is index1) and the third argument(that is index2) with a space in-between the two string.

6 0
3 years ago
Which of the following examples illustrates the Crowding Out Effect?
maks197457 [2]

your answer is c to what your looking for



6 0
3 years ago
Other questions:
  • Which one of the following items would you be most likely to keep in a database ?
    8·1 answer
  • Generally speaking, manufacturing overhead is applied to production by means of a __________ __________ __________, which is com
    11·2 answers
  • The goal expressed in this definition states that data visualization is about ________________ .
    11·2 answers
  • _____ is the management function that monitors the performance of the firm and makes improvements when necessary
    15·1 answer
  • Examine the following algorithm.
    9·1 answer
  • Which of the following is considered a basic task in the context of computer operations? a. Connecting to the Internet b. Natura
    6·1 answer
  • Binary is best interpreted by a computer because ​
    12·2 answers
  • What are hardware and software?<br><br><br><br> WILL MARK BRAINIEST
    9·2 answers
  • Which is an example of a demand account
    10·1 answer
  • Multiple Select
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!