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...
-
GPCRs activate G proteins by reducing the strength of GDP binding to the G protein. This results in rapid dissociation of bound GDP, which is then replaced by GTP, because GTP is present in the...
-
Perform a thorough influential analysis of the air pollution and mortality data given in Table B.15. Perform any appropriate transformations. Discuss your results. City Mort Precip Educ Nonwhite Nox...
-
A manufacturer of a new pain relief tablet would like to demonstrate that its product works twice as fast as the competitors product. Specifically, the manufacturer would like to test Where μ1 is...
-
In a dealer market, the ask price is the highest price the dealer offered to buy a security and the bid price is the lowest price the dealer offered to sell a security. The difference of the ask...
-
There are 2 shinobis with chakra levels 5 and 10 respectively and the desired sum of chakra levels is utmost 15 Starting with ke0, suy of chakra levels after attack max(5-0,0) + max(10- 0,0) 5+10 15....
-
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.
-
A small company manufactures picnic tables. The weekly fixed cost is $1,200 and the variable cost is $45 per table. Find the total weekly cost of producing x picnic tables. How many picnic tables can...
-
Iwo canoeists, A and live on opposite shores of a 300.0 m wide niver that flows east at 0.80 m/s. A lives on the north shore and B lives on the south shore. They both set out to visit a mutual friend...
-
Give a definition for density, and provide the SI units for it. Make a prediction about the approximate weight (in Newtons) of the air in the room you are currently occupying by taking the following...
-
How much pressure is applied to the ground by a 108 kg man who is standing on square stilts that measure 0.05 m on each edge? Answer in units of Pa. 003 (part 2 of 2) 10.0 points What is this...
-
How much work is done lifting a 15 pound object from the ground to the top of a 25 foot building if the cable used weighs 1.5 pounds per foot? Question 2 A bucket begins weighing 20 pounds,...
-
A Proton X70 starts from rest and travels along Jalan Kuantan-Gambang with constant acceleration. The car manages to achieve velocity of 15 m/s within 200 m of distance. Determine the acceleration...
-
A diesel-powered tractor with a cost of $180,000 and estimated residual value of $18,000 is expected to have a useful operating life of 36,000 hours. During February, the tractor was operated 156...
-
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
-
Sell of Process Further Rose Hill, a soybean farm in northern Minnesota, has a herd of 50 dairy cows. The cows produce approximately 2,800 gallons of milk per week. The farm currently sells all its...
-
The 3 promotional methods to use will include digital marketing, word to mouth and branding. D g. Part 4: Promotional Strategy i. Identify a promotional mix consisting of at least three promotional...
-
Wu Inc. Statement of Income Year Ended August 31, 2024 Service revenue Operating expenses Income before income tax Income tax expense Net income Wu Inc. $ 325,000 [1] 116,000 23,000 $ [2] Statement...
Study smarter with the SolutionInn App