Create a script to input 2 numbers from the user. The script will then ask the user to perform a numerical calculation of addition, subtraction, multiplication, or division. Once the calculation is performed, the script will end.

Answers

Answer 1

Answer:

The code given is written in C++

First we declare the variables to be used during the execution. The names given are self-explanatory.

Then the program outputs a request on the screen and waits for user input, for both numbers and one more time for the math operation wanted, selected with numbers 1 to 4.

Finally, the program executes the operation selected and outputs the result on screen.  

Code:

#include <iostream>

int main()

{

// variable declaration

float numberA;

float numberB;

int operation;

float result=0;

//number request

std::cout<<"Type first number:\n"; std::cin>>numberA;

std::cout<<"Type second number:\n"; std::cin>>numberB;

 

//Operation selection

cout << "Select an operation\n";

cout << "(1) Addition\n";

cout << "(2) Subtraction\n";

cout << "(3) Multiplication\n";

cout << "(4) Division\n";

std::cout<<"Operation:\n"; std::cin>>operation;

switch(operation){

 case 1:

  result = numberA+numberB;

  break;

 case 2:

  result = numberA-numberB;

  break;

 case 3:

  result = numberA*numberB;

  break;

 case 4:

  result = numberA/numberB;

  break;    

 default:

  std::cout<<"Incorrect option\n";

 }

//Show result

std::cout<<"Result is:"<<result<<::std::endl;

return 0;

}


Related Questions

what does libtard mean

Answers

Answer:

Normally, It is a person of the opposite political belief that thinks that liberals/leftists are stupid for what they say. Most of the time, this "insult" is mostly used by Right-Winged Conservitives or used as a joke by leftists to show how funny it is when conservitives say it.

Answer:

it means a liberal r3tard. lib-tard

Explanation:

HELP PLEASE

Today, not only do companies employ public relations managers but so do many
celebrities and politicians. Research and explain what the role of a public relations
manager is and see if you can think of the reasons why many public figures seem
to find them useful.

Answers

Answer: The role of a public relations manager is to keep the image of a celebrity, politician, ect. good so that they can keep their career going while constantly in the eye of the public. Public figures may find this useful because it can help them keep their record clean and have a personal life while also making it seem like they are perfect people to their audience, which in hand can help with business.

Explanation:

Write a program that prompts the user to enter a Social Security number in the format ddd-dd-dddd, where d is a digit. The program displays Valid SSN for a correct Social Security number or Invalid SSN otherwise.

Answers

ssn = input("Enter a valid Social Security number: ")

dashes = 0

nums = 0

message = "Invalid SSN"

if len(ssn) == 11:

   for x in ssn:

       if x.isdigit():

           nums += 1

       elif x == "-":

           dashes += 1

if nums == 9 and dashes == 2:

   message = "Valid SSN"

print(message)

I wrote my code in python 3.8. I hope this helps!

The program that prompts the user to enter a Social Security number in the format ddd-dd-dddd, where d is a digit can be implemented in Python using regular expressions. The regular expression pattern for the SSN format can be used to validate the input.

Pythons code:

```python

import re

ssn_pattern = re.compile(r'^\d{3}-\d{2}-\d{4}$')

ssn = input("Enter your Social Security Number (format: ddd-dd-dddd): ")

if ssn_pattern.match(ssn):

print("Valid SSN")

else:

print("Invalid SSN")

```

In the above code, we first import the `re` module to work with regular expressions.

We then define the regular expression pattern for the SSN format as `^\d{3}-\d{2}-\d{4}$`. This pattern matches any string that starts with three digits, followed by a hyphen, then two digits, another hyphen, and finally, four digits.

We then prompt the user to enter their SSN using the `input()` function. We then check if the entered SSN matches the pattern using the `match()` function of the regular expression object `ssn_pattern`.

If the SSN matches the pattern, we print "Valid SSN". Otherwise, we print "Invalid SSN".

Know more about SSN,

https://brainly.com/question/31778617

#SPJ4

If anyone has the answer for this that would be really helpful!!

Answers

Hope this will help you...

Answer:

1.a

2.f

3.b

4.c

5.e

6.g

7.h

8.d

Explanation:

Other Questions
This is just a made up question I made.6(2 + 9) - 11 4t^2-6 when t is 3 Math question If you swim the 100 IM what strokes are involved? Butterfly, Side stroke, Breaststroke, Freestyle Butterfly, Backstroke, Breaststroke, Freestyle Butterfly, Elementary backstroke, Breaststroke, Freestyle Butterfly, Tactical side stroke, Breaststroke, Freestyle A cement truck when filled weighs 42 000 N. Calculate its mass For this topic sentence, what is the best, most logical order for the following sentences? Topic sentence: Salt is the most important spice in the world. 1: Without salt, our food would be bland and boring indeed. II: Even baked goods need salt in order to taste right, and there is nothing more delicious than fresh sea salt sprinkled on a piece of dark chocolate. III: What good would most savory food be without salt? A soup is not a soup without a healthy dose of salt to bring out the flavors of the vegetables. O O A. I, II, III B. I, II, II O C. III, I, II D. III, II, I PLEASEEE HELP I will give 14 points 20 POINTS What role do animals have in the carbon cycle?Group of answer choicesuse water and release oxygenuse sugar and release carbonuse carbon and release oxygenuse carbon and release nitrogen Read the passage from the Torah. I am the Lord, your God, Who took you out of the land of Egypt, out of the house of bondage. You shall not have the gods of others in My presence. . . . You shall neither prostrate yourself before them nor worship them, for I, the Lord, your God, am a zealous God, Who visits the iniquity of the fathers upon the sons, upon the third and the fourth generation of those who hate Me. Exodus 20:25 Which Jewish belief is represented in this passage? What makes cultures endure? If a, b are real numbers and 7a + i(3a - b) = 14 - 6i , then find the values of a and b. Alberts father is 24 years older than Albert. In 8 years, his father will be twice as old as Albert. How old is Albert now? How old is his father? What does Jonny leave for Ponyboy?A. The book Gone With the WindB. His hair greaseC. The poem Nothing Gold Can StayD. His switchable why did forced labor continue after the Civil war? What statement describes how light travels from a source describe the difference between particle motion in solids and liquids. The Great Basin cultures of Utes and Shoshone lived in the region of the United States that is nowNevada and UtahMontana and WashingtonArizona and New MexicoWashington and Oregon What did the Nineteenth Amendment allow? Canada?Please answer, my teachers are complete nitwits A universal shift register can shift in both the left-to-right and right-to-left directions, and it has parallel-load capability. Draw a circuit for such a shift register. what is this reference:wenlocktoad-sama