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
Elenna [48]
3 years ago
7

Create a script to input 2 numbers from the user. The script will then ask the user to perform a numerical calculation of additi

on, subtraction, multiplication, or division. Once the calculation is performed, the script will end.
Computers and Technology
1 answer:
ohaa [14]3 years ago
5 0

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:

<em>#include <iostream> </em>

<em> int main() </em>

<em>{ </em>

<em> // variable declaration </em>

<em> float numberA; </em>

<em> float numberB; </em>

<em> int operation; </em>

<em> float result=0; </em>

<em> </em>

<em> //number request </em>

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

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

<em>  </em>

<em> //Operation selection </em>

<em> cout << "Select an operation\n"; </em>

<em> cout << "(1) Addition\n"; </em>

<em> cout << "(2) Subtraction\n"; </em>

<em> cout << "(3) Multiplication\n"; </em>

<em> cout << "(4) Division\n"; </em>

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

<em> </em>

<em> switch(operation){ </em>

<em>  case 1: </em>

<em>   result = numberA+numberB; </em>

<em>   break; </em>

<em>  case 2: </em>

<em>   result = numberA-numberB; </em>

<em>   break; </em>

<em>  case 3: </em>

<em>   result = numberA*numberB; </em>

<em>   break; </em>

<em>  case 4: </em>

<em>   result = numberA/numberB; </em>

<em>   break;    </em>

<em>  default: </em>

<em>   std::cout<<"Incorrect option\n"; </em>

<em>  }</em>

<em> //Show result </em>

<em> std::cout<<"Result is:"<<result<<::std::endl; </em>

<em> return 0; </em>

<em>}</em>

You might be interested in
guys im so heartbroken. so i quit art. heres my laST piece of art i did. it took me a month. im burning it tonight. i quit art..
Helga [31]

Answer:

Ok

hsjsbsjwiqnsbsjsowiwi

5 0
3 years ago
Read 2 more answers
Design a RomanNumerals class that takes a number within 1 to 10 and display the Roman numeral version of that number (I, II, III
Alla [95]

Answer:

Explanation:

The following code is written in Java. It  creates a RomanNumberals class with all of the requested methods, including a convertNum method and displayResults method. The user is then asked to input a number within the main method. A RomanNumeral object is created, passed the userInput and all of it's methods are called for testing. A test output can be seen in the attached image below.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter a number: ");

       int number = in.nextInt();

       RomanNumerals romanNumeral1 = new RomanNumerals();

       romanNumeral1.setNumber(number);

       System.out.println("Test getNumber Method: " + romanNumeral1.getNumber());

       romanNumeral1.convertNumber();

       romanNumeral1.displayResult();

   }

}

class RomanNumerals {

   int number;

   String romanNumeral;

   public RomanNumerals() {

   }

   public int getNumber() {

       return number;

   }

   public void setNumber(int number) {

       this.number = number;

   }

   public void convertNumber() {

       switch (this.number) {

           case 1: romanNumeral = "I"; break;

           case 2: romanNumeral = "II"; break;

           case 3: romanNumeral = "III"; break;

           case 4: romanNumeral = "IV"; break;

           case 5: romanNumeral = "V"; break;

           case 6: romanNumeral = "VI"; break;

           case 7: romanNumeral = "VII"; break;

           case 8: romanNumeral = "VIII"; break;

           case 9: romanNumeral = "IX"; break;

           case 10: romanNumeral = "X"; break;

           default: System.out.println("Not a valid number"); break;

       }

   }

   public void displayResult() {

       System.out.println("Number " + this.number + " is represented as " + this.romanNumeral);

   }

}

7 0
3 years ago
What are the unique technology that characterised each generation of computer ​
Svetach [21]

Technology used: Transistor. Operating speed was in terms of a microsecond. Assembly language and machines independent language such as COBOL (Common Business Oriented Language) and FORTRAN (Formula Translation) were introduced the size of the computer. Magnetic core memory was used as primary memory.

7 0
3 years ago
When using straight ladder ,the base of the ladder should be___away from the wall
dusya [7]
It should be angled away from the wall like |\
3 0
3 years ago
what should i do after learning python? how can I make apps or gaming apps? IF YOUR ANSWER WILL BE GOOD I WILL MARK AS BRAINLIES
seraphim [82]

Answer:

Here are some of the things that you can do after learning Python:

Learn a Web Development Framework

Learn Machine Learning

Start Teaching Python to Beginners (and earn some bucks)

These are the top three ways to proceed

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • . What are the disadvantages of using small, fixed-length cells in ATM?
    13·2 answers
  • What command prompts should be used to assign an IP address to:
    9·1 answer
  • Given a UNIX file system with 1024-byte blocks, how many disk accesses are needed to access bytes 2500-2503 of a file (assume th
    12·1 answer
  • Analyze the following code:
    8·1 answer
  • Page Up and Page Down keys fall under the ? keys category.
    14·2 answers
  • When you expand the virtual size of a game, what do you create?
    7·1 answer
  • What woman ran for president on the National Equal Rights Party, receiving 4,149 votes in 6 states in 1884?
    5·1 answer
  • What is the school wifi password trying to do my class work in school on different devices.
    9·1 answer
  • Difference between tell() and seek().​
    11·1 answer
  • Which of the following is an object-oriented programming language?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!