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
Water at 15°C is to be discharged from a reservoir at a rate of 18 L/s using two horizontal cast iron pipes connected in series
love history [14]

Answer:

The required pumping head is 1344.55 m and the pumping power is 236.96 kW

Explanation:

The energy equation is equal to:

\frac{P_{1} }{\gamma } +\frac{V_{1}^{2}  }{2g} +z_{1} =\frac{P_{2} }{\gamma } +\frac{V_{2}^{2}  }{2g} +z_{2}+h_{i} -h_{pump} , if V_{1} =0,z_{2} =0\\h_{pump} =\frac{V_{2}^{2}}{2} +h_{i}-z_{1}

For the pipe 1, the flow velocity is:

V_{1} =\frac{Q}{\frac{\pi D^{2} }{4} }

Q = 18 L/s = 0.018 m³/s

D = 6 cm = 0.06 m

V_{1} =\frac{0.018}{\frac{\pi *0.06^{2} }{4} } =6.366m/s

The Reynold´s number is:

Re=\frac{\rho *V*D}{u} =\frac{999.1*6.366*0.06}{1.138x10^{-3} } =335339.4

\frac{\epsilon }{D} =\frac{0.00026}{0.06} =0.0043

Using the graph of Moody, I will select the f value at 0.0043 and 335339.4, as 0.02941

The head of pipe 1 is:

h_{1} =\frac{V_{1}^{2}  }{2g} (k_{L}+\frac{fL}{D}  )=\frac{6.366^{2} }{2*9.8} *(0.5+\frac{0.0294*20}{0.06} )=21.3m

For the pipe 2, the flow velocity is:

V_{2} =\frac{0.018}{\frac{\pi *0.03^{2} }{4} } =25.46m/s

The Reynold´s number is:

Re=\frac{\rho *V*D}{u} =\frac{999.1*25.46*0.03}{1.138x10^{-3} } =670573.4

\frac{\epsilon }{D} =\frac{0.00026}{0.03} =0.0087

The head of pipe 1 is:

h_{2} =\frac{V_{2}^{2}  }{2g} (k_{L}+\frac{fL}{D}  )=\frac{25.46^{2} }{2*9.8} *(0.5+\frac{0.033*36}{0.03} )=1326.18m

The total head is:

hi = 1326.18 + 21.3 = 1347.48 m

The required pump head is:

h_{pump} =\frac{25.46^{2} }{2*9.8} +1347.48-36=1344.55m

The required pumping power is:

P=Q\rho *g*h_{pump}  =0.018*999.1*9.8*1344.55=236965.16W=236.96kW

8 0
3 years ago
Independent auto lots usually have ____ finance rates than dealerships
wel

Independent auto lots usually have <u>higher</u> finance rates than dealerships

<u>Explanation:</u>

The finance rates that are charged by the dealers are lower than the finance charges that are charged by the independent auto. In case if you are getting financed through dealerships, you can also negotiate with them to charge finance rates and lower the charges of the finance.

But this negotiation and lowering of the finance rates is not possible with the independent auto lots and thus they charge higher rates compared to the dealerships.

8 0
3 years ago
Steam at 4 MPa and 350°C is expanded in an adiabatic turbine to 125kPa. What is the isentropic efficiency (percent) of this turb
guajiro [1.7K]

Answer:

\eta_{turbine} = 0.603 = 60.3\%

Explanation:

First, we will find actual properties at given inlet and outlet states by the use of steam tables:

AT INLET:

At 4MPa and 350°C, from the superheated table:

h₁ = 3093.3 KJ/kg

s₁ = 6.5843 KJ/kg.K

AT OUTLET:

At P₂ = 125 KPa and steam is saturated in  vapor state:

h₂ = h_{g\ at\ 125KPa} = 2684.9 KJ/kg

Now, for the isentropic enthalpy, we have:

P₂ = 125 KPa and s₂ = s₁ = 6.5843 KJ/kg.K

Since s₂ is less than s_g and greater than s_f at 125 KPa. Therefore, the steam is in a saturated mixture state. So:

x = \frac{s_2-s_f}{s_{fg}} \\\\x = \frac{6.5843\ KJ/kg.K - 1.3741\ KJ/kg.K}{5.91\ KJ/kg.K}\\\\x = 0.88

Now, we will find h_{2s}(enthalpy at the outlet for the isentropic process):

h_{2s} = h_{f\ at\ 125KPa}+xh_{fg\ at\ 125KPa}\\\\h_{2s} = 444.36\ KJ/kg + (0.88)(2240.6\ KJ/kg)\\h_{2s} = 2416.088\ KJ/kg

Now, the isentropic efficiency of the turbine can be given as follows:

\eta_{turbine} = \frac{h_1-h_2}{h_1-h_{2s}}\\\\\eta_{turbine} = \frac{3093.3\ KJ/kg-2684.9\ KJ/kg}{3093.3\ KJ/kg-2416.088\ KJ/kg}\\\\\eta_{turbine} = \frac{408.4\ KJ/kg}{677.212\ KJ/kg}\\\\\eta_{turbine} = 0.603 = 60.3\%

3 0
3 years ago
1. Under what conditions can soils be chemically stabilized?
marshall27 [118]

Answer:

All will be Explained below.

Explanation:

1) Under which Condition can a soil be chemically Stabilize.

Answer

a). Plasticity Index :A soil with a high value of plasticity Index is not good for various engineering projects. The introduction of line helps in reducing plasticity due cation exchange reaction.Pozzolanic reaction over time reduces plasticity and increase index strength due to the formation of calcium - silicate hydrate.

7 0
4 years ago
British standered institution
Scorpion4ik [409]

Answer:

The British Standards Institution, is the national standards body of the United Kingdom. BSI produces technical standards on a wide range of products and services and also supplies certification and standards-related services to businesses

6 0
3 years ago
Other questions:
  • Vehicles arrive at a single toll booth beginning at 8:00 A.M. They arrive and depart according to a uniform deterministic distri
    9·1 answer
  • What is the heights part of Maine?
    5·1 answer
  • A room is cooled by circulating chilled water through a heat exchanger located in the room. The air is circulated through the he
    15·1 answer
  • The Greek alphabet has 24 distinct lowercase letters. How many bits are needed to be able to encode any single lowercase Greek l
    9·1 answer
  • If you are a subcontractor in the leather and apparel industry, you might make any of the following items EXCEPT which
    7·1 answer
  • Complete the following sentence.
    10·1 answer
  • In order to be a Mechanical Engineer, you need to:
    5·2 answers
  • Wells drilled by a nonprofit called Water for South Sudan use a pump that can provide up to 5,500 gallons of water per day. Use
    10·1 answer
  • Jack has been concerned about the rapidly changing green regulations in his state and his ability as a mechanical engineer to ke
    13·1 answer
  • On diesel engines, data from ________ sensors are commonly used to adjust exhaust gas recirculation (EGR) rates.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!