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
gregori [183]
3 years ago
7

Create a program that displays a menu to select addition, subtraction, or multiplication. Using random numbers between 0 and 12

(including 0 and 12), present a math problem of the type selected to the user. Display a "correct" or "incorrect" message after the user enters their answer. In C++
Computers and Technology
1 answer:
Lemur [1.5K]3 years ago
6 0

Answer:

This question is answered using C++

#include<iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

int main(){

   int ope, yourresult;

   cout<<"Select Operator: \n"<<"1 for addition\n"<<"2 for subtraction\n"<<"3 for multiplication\n";

   cout<<"Operator: ";

   cin>>ope;

   srand((unsigned) time(0));

   int num1 = rand() % 12;

   int num2 = rand() % 12;

   int result = 1;

   if(ope == 1){

       cout<<num1<<" + "<<num2<<" = ";

       result = num1 + num2;

   }

   else if(ope == 2){

       cout<<num1<<" - "<<num2<<" = ";

       result = num1 - num2;

   }

   else if(ope == 3){

       cout<<num1<<" * "<<num2<<" = ";

       result = num1 * num2;

   }

   else{

       cout<<"Invalid Operator";

   }

   cin>>yourresult;

   if(yourresult == result){

       cout<<"Correct!";

   }

   else{

       cout<<"Incorrect!";

   }

   return 0;

}

Explanation:

This line declares operator (ope) and user result (yourresult) as integer

   int ope, yourresult;

This prints the menu

   cout<<"Select Operator: \n"<<"1 for addition\n"<<"2 for subtraction\n"<<"3 for multiplication\n";

This prompts the user for operator

   cout<<"Operator: ";

This gets user input for operator

   cin>>ope;

This lets the program generates different random numbers

   srand((unsigned) time(0));

This generates the first random number

   int num1 = rand() % 12;

This generates the second random number

   int num2 = rand() % 12;

This initializes result to 1

   int result = 1;

If the operator selected is 1 (i.e. addition), this prints an addition operation and calculates the actual result

<em>    if(ope == 1){</em>

<em>        cout<<num1<<" + "<<num2<<" = ";</em>

<em>        result = num1 + num2;</em>

<em>    }</em>

If the operator selected is 2 (i.e. subtraction), this prints an subtracttion operation and calculates the actual result

<em>    else if(ope == 2){</em>

<em>        cout<<num1<<" - "<<num2<<" = ";</em>

<em>        result = num1 - num2;</em>

<em>    }</em>

If the operator selected is 3 (i.e. multiplication), this prints an multiplication operation and calculates the actual result

<em>    else if(ope == 3){</em>

<em>        cout<<num1<<" * "<<num2<<" = ";</em>

<em>        result = num1 * num2;</em>

<em>    }</em>

If selected operator is not 1, 2 or 3, the program prints an invalid operator selector

<em>    else{</em>

<em>        cout<<"Invalid Operator";</em>

<em>    }</em>

This gets user input

   cin>>yourresult;

This checks if user result is correct and prints "Correct!"

   if(yourresult == result){

       cout<<"Correct!";

   }

If otherwise, the program prints "Incorrect!"

<em>    else{</em>

<em>        cout<<"Incorrect!";</em>

<em>    }</em>

   return 0;

You might be interested in
Which software application offers a variety of templates for creating reports, flyers, and newsletters that you can access withi
dedylja [7]
D. Word processing software
3 0
3 years ago
It's a holiday poop in my bitt
Zina [86]

Answer:

bitt

Explanation:

pp

4 0
3 years ago
Read 2 more answers
A(n) _________ is a lan that uses the same technologies as the internet but is provided to invited users outside the organizatio
In-s [12.5K]

Solution:

A(n) extranet  is a lan that uses the same technologies as the internet but is provided to invited users outside the organization who access it over the internet.

An extranet is a private network that uses Internet technology and the public telecommunication system to securely share part of a business's information or operations with suppliers, vendors, partners, customers, or other businesses. An extranet can be viewed as part of a company's intranet that is extended to users outside the company. It has also been described as a "state of mind" in which the Internet is perceived as a way to do business with other companies as well as to sell products to customers.

This is the right answer.

3 0
3 years ago
I AM GIVING BRAINLEST!!!!!!!!
elena-s [515]

Answer:

B. 10%

Explanation:

The JPG file is a great format as it often manages to compress files to 1/10 of the size of the original file which is especially good for saving on bandwidth. JPG is a popular graphic format, which is characterized by a high degree of compression, which leads to a decrease in image quality.

6 0
3 years ago
Read 2 more answers
True false) ther are five arrow keys on the keborad​
cluponka [151]

Answer:

false, there's only 4

Explanation:

5 0
3 years ago
Other questions:
  • Victoria enjoys laughing with her friends as they walk around the track after school. Which best describes her hate rate during
    5·1 answer
  • • What is the difference between primary storage, secondary storage, and off-line storage
    10·1 answer
  • Which fingers should you use to type the reach keys?
    12·1 answer
  • How can a user view the options for Junk E-mail?
    11·2 answers
  • Theodor is researching computer programming. He thinks that this career has a great employment outlook, so he'd like to learn if
    9·2 answers
  • Piers wants to take a course on XML. He is a certified web designer, but he has not used XML before. How can he use XML to impro
    8·1 answer
  • Jack used primarily web sources for his informative speech about gun control. however, his over-reliance on the web site sponsor
    11·1 answer
  • Who was the father of computer​
    10·1 answer
  • Why do we use the internet so much?​
    6·1 answer
  • Would my phone still work if I snapped it in half?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!