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
GrogVix [38]
4 years ago
10

Write a simple calculator program. Your program should ask for three things two whole numbers and an operator in the form of an

expression like: 3 * 2 Use a select case structure to determine what operation needs to be performed on the two numbers. Your program should handle the arithmetic functions Add, Subtract, Multiply, and Divide (Depending on the operator entered).
Engineering
1 answer:
vekshin14 years ago
3 0

Answer:

The solution code is written in Java.

  1.        Scanner input = new Scanner(System.in);
  2.        System.out.print("Enter operator: ");
  3.        String operator = input.nextLine();
  4.        System.out.print("Enter first integer: ");
  5.        int num1 = input.nextInt();
  6.        System.out.print("Enter second integer: ");
  7.        int num2 = input.nextInt();
  8.        int result = 0;
  9.        switch(operator){
  10.            case "+":
  11.               result = num1 + num2;
  12.               break;
  13.            case "-":
  14.                result = num1 - num2;
  15.                break;
  16.            case "*":
  17.                result = num1 * num2;
  18.                break;
  19.            case "/":
  20.                result = num1 / num2;
  21.                break;
  22.            default:
  23.                System.out.println("Invalid operator");
  24.        }
  25.        System.out.println(result);

Explanation:

To ask for the user input for two whole numbers and an operator, we can use Java Scanner class object. Since the input operator is a string, we can use nextLine() method to get the operator string (Line 3). We use nextInt() method to get whole number input (Line 5 & 7).

Next we use the switch keyword and pass the operator into the switch structure to determine which case statement should be executed. For example,  if the input operator is "*" the statement  "<em>result = num1 * num2;</em> " will run and multiply <em>num1</em> with <em>num2. </em>

You might be interested in
An aluminum cylinder bar ( 70 GPa E m = ) is instrumented with strain gauges and is subject to a tensile force of 5 kN. The diam
Stells [14]

Find the complete solution in the given attachments.

Note: The complete Question is attached in the first attachment as the provided question was incomplete

7 0
4 years ago
What is the governing ratio for thin walled cylinders?
Ann [662]

Answer:

The governing ratio for thin walled cylinders is 10 if you use the radius. So if you divide the cylinder´s radius by its thickness and your result is more than 10, then you can use the thin walled cylinder stress formulas, in other words:

  • if \frac{radius}{thickness} >10 then you have a thin walled cylinder

or using the diameter:

  • if \frac{diameter}{thickness} >20 then you have a thin walled cylinder
3 0
3 years ago
Design roller chain drive. Specify the chain size, the sizes and number of teeth in the sprockets, the number of chain pitches,
Rom4ik [11]

Answer:

The total design can be summarized as follows:

AC motor 55 hp, 750 rpm  as a driver

Service factor 1.0

Design power 5 hp

No. 40 chain, 0.50 in pitch, 1 strands

17 teeth, 2.72 in pitch dia, 1 strand small sprocket

39 teeth, 7.46 in pitch dia, 1 strand large sprocket

1 strand of length 54 in

Center distance of 19.9 in

Actual Output speed of 326.9 rpm

Type B lubrication

Explanation:

4 0
3 years ago
A metal specimen with an original diameter of 0.50 in. and a gauge length of 2.75 in. is tested in tension until a fracture occu
tatiyna

Answer:

Percent Elongation = 52.72%

Percent Reduction in Area = 64%

Explanation:

First we find percent elongation:

Percent Elongation = {Final Gage Length - Initial Gauge Length/Initial Guage Length} x 100%

Percent Elongation = {(4.20 in - 2.75 in)/2.75 in} x 100%

<u>Percent Elongation = 52.72%</u>

Now, for the percent reduction in area:

Percent Reduction in Area = {Final Cross Sectional Area - Initial Cross Sectional Area|/Initial Cross Sectional Area Length} x 100%

Percent Reduction in Area = {π(0.3 in)² - π(0.5 in)²/π(0.5 in)²} x 100%

<u>Percent Reduction in Area = - 64%</u>

here, negative sign shows a decrease in area.

5 0
3 years ago
You need to wear respiratory PPE whenworking around materials that may contain asbestos
choli [55]

Answer:

to prevent asbestos fibers poisoning

Explanation:

There is a potential for asbestos fibers to be released when removing asbestos-containing material,using personal protective equipment will significantly reduce your exposure to asbestos fibers.

7 0
2 years ago
Other questions:
  • To be safe, the engineers making the ride want to be sure the normal force does not exceed 1.8 times each persons weight - and t
    11·1 answer
  • All of the following statements are true EXCEPT: A) air should be let out of a tire when it is hot. B) each change in outside te
    11·1 answer
  • Java Programming: Loops and Conditionals
    13·1 answer
  • What are some common ways of converting fuel to useful energy? Check all that apply.
    9·2 answers
  • A plane wall, 7.5 cm thick, generates heat internally at the rate of 105W/m3. One side of the wall is insulated and the other si
    14·1 answer
  • In software engineering how do you apply design for change?
    13·1 answer
  • How does an electric circuit work?<br><br> Please give a detailed answer- thx
    8·2 answers
  • Daniel Wiseman, a scientist for Gres-Trans Corp., wants to determine if the flow rate of a particular material changes with diff
    9·1 answer
  • Name the manufacturing process that the worker is using to create the workpiece. The manufacturing process carried out by the bl
    6·1 answer
  • The A/C compressor will not engage when the A/C is turned on. The static refrigerant pressure is 75 psi and the outside temperat
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!