Show the modifications needed to add exponentiation to the class Calculator in Listing 9.12. Use ^ to
Question:
Show the modifications needed to add exponentiation to the class Calculator in Listing 9.12. Use ^ to indicate the exponentiation operator and the method Math.pow to perform the computation.
Listing 9.12.
Transcribed Image Text:
import java.util.Scanner; /** Simple line-oriented calculator program. The class can also be used to create other calculator programs. */ public class Calculator { private double result; private double precision = 0.0001; // Numbers this close to zero are treated as if equal to zero. public static void main (String [] args) { Calculator clerk = new Calculator (); try { System.out.printin("Calculator is on."); System.out.print ("Format of each line: "); System.out.println("operator space number"); System.out.println("For example: + 3"); System.out.printin("To end, enter the letter e."); clerk.doCalculation (); catch (UnknownOpException e) { clerk.handleUnknownOpException (e); catch (DivideByZeroException e) { clerk.handleDivideByZeroException (e); } System.out.println ("The final result is %3D + clerk.resultValue ()); System.out.println ("Calculator program ending."); } public Calculator () { result = 0;
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 42% (7 reviews)
case THIS ...View the full answer
Answered By
Benard Ndini Mwendwa
I am a graduate from Kenya. I managed to score one of the highest levels in my BS. I have experience in academic writing since I have been working as a freelancer in most of my time. I am willing to help other students attain better grades in their academic portfolio. Thank you.
4.90+
107+ Reviews
240+ Question Solved
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Question Posted:
Students also viewed these Computer science questions
-
Use your calculator to make computation in problem 1 directly In problem 1 (a) In 6 (b) In 1.5 (c) In 81 (d) In 2 (e) In(1/36) (f) In 48
-
Perform the same computation as in Sec. 24.2, but use Gauss quadrature to evaluate the integral.
-
In a math class with 200 students, suppose that the students' decisions to attend the class are independent, and each student attends with probability 93%. On a given day, find the approximate...
-
0 The initial substitution of x = a yields the form Simplify the function algebraically, or use a table or 0 graph to determine the limit. When necessary, state "DNE". x + 4x-5 x - 1 Step 1: Factor...
-
Consider an ideal gas-turbine cycle with one stage of compression and two stages of expansion and regeneration. The pressure ratio across each turbine stage is the same. The highpressure turbine...
-
Answer the following question. How many U.S. dollars can you buy for C$750 if one Canadian dollar is worth US$0.8168?
-
A diesel engine has a compression ratio of 20 and cut-off takes place at 5\% of the stroke. Find the air-standard efficiency. Assume \(\gamma=1.4\).
-
Presented below and on page 678 are three independent situations. 1. Longbine Corporation redeemed $130,000 face value, 12% bonds on June 30, 2017, at 102. The carrying value of the bonds at the...
-
How does Process Analytical Technology (PAT) support real-time monitoring and control in bioprocessing, and what impact does it have on process optimization and product consistency ?
-
Revolving Wings (RW) is a Kalamazoo, Michigan, manufacturer of equipment for the renewable energy sector. The company has a strong domestic market for their fiberglass composite wind turbine blades....
-
Write an application that implements a trip-time calculator. Define and use a class TripComputer to compute the time of a trip. TripComputer should have the private attributes totalTimethe total time...
-
Write a program that will write the Gettysburg Address to a text file. Place each sentence on a separate line of the file.
-
There are two people (A&B) and two goods (1&2). One production process is available with a production function y2 (y1) = 2y1. The two people are endowed with a total of 60 units of good 1 (we do not...
-
Under the gold standard, if country J imports more than it exports, it has to ship ________to the trading partners with whom it has trade deficits. This will depress country Js ____________, and its...
-
A monopoly would have a concentration ratio of _______and a Herfindahl Hirschman index of __________. a) 100, 100 b) 10,000, 10,000 c) 10,000, 100 d) 100, 10,000
-
Is convergence guaranteed always with Jacobi and Gauss-Siedel methods, as applied to iterative solutions of linear algebraic equations? (a) Yes (b) No
-
Imports have made the automobile industrys concentration ratio much relevant, while the Japanese transplants have been that ratio. a) more, reducing b) more, increasing c) less, reducing d) less,...
-
A duopoly would have a concentration ratio of. a) 0 b) 50 c) 100 d) an indeterminate amount.
-
Light passes through a single slit. If the width of the slit is reduced, what happens to the width of the central bright fringe? (a) The width of the central bright fringe does not change, because it...
-
What is the shape of the exponential distribution?
-
What is the required bandwidth for the following cases if we need to send 4000 bps? Let d = 1. a. ASK b. FSK with 2f = 4 KHz c. QPSK d. 16-QAM
-
What are the two components of a signal when the signal is represented on a constellation diagram? Which component is shown on the horizontal axis? Which is shown on the vertical axis?
-
How many bits per baud can we send in each of the following cases if the signal constellation has one of the following number of points? a. 2 b. 4 c. 16 d. 1024
-
Draw the shear diagram for the beam. Set P = 600 lb, a = 5 ft, b = 7 ft. Draw the moment diagram for the beam.
-
Ahmed, Bassem and Jamal are partners in Tadamon Company who share profits and losses at a ratio of 2 : 2 : 4 respectively. On 1 / 1 / 2 0 2 2 , it was decided to liquidate the company, and the...
-
Draw the shear diagram for the beam. Follow the sign convention. Draw the moment diagram for the beam. Follow the sign convention.
Study smarter with the SolutionInn App