Write java program that can serve as simple calculator

Assignment Help Computer Engineering
Reference no: EM1329857

Write a Java program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0. Each cycle allows the user to repeatedly add, subtract, multiply, or divide by a second number. The result of one of these operations becomes the new value of result. The calculation ends when the user enters the letter "R" or "r" for 'result'. The user is allowed to do another calculation from the beginning as often as desired.

The input format is shown in the following sample dialogue. If the user enters any operator symbol other than "+,-,*, or /", then an UnknownOperatorException is thrown and the user is asked to reenter that line of input. Define the class UnknownOperatorException appropriately.

Calculator is on
result = 0.0
+5
result + 5.0 = 5.0
new result = 5.0
*2.2
result * 2.2 = 11.0
updated result = 11.0
%10
% is an unknown operation.
Reenter, your last line:
*0.1
result * 0.1 = 1.1
updated result = 1.1
r
Final result = 1.1
Do you want calculate again? (y/n)
yes
result = 0.0
+10
result + 10.0 = 10.0
new result = 10.0
/2
result / 2.0 = 5.0
updated result = 5.0
R
Final result = 5.0
Do you want calculate again? (y/n)
N
End of Program

Reference no: EM1329857

Questions Cloud

The key ingredients to success : What are the key ingredients to success in a Consignment Store?
Elements of the innovative process : Elements of the Innovative process - Write a paper in which you examine the elements of the innovative process as well as compare and contrast incremental
Assume if the inflation rate is this still acceptable : Assume if the inflation rate is 5percent is this still acceptable. Provide quantitative justification for your answer.
What is strategy formulation and execution : How has FedEx managed to maintain technical superiority (i.e., reliability, service, package tracking, etc.) in its industry? Can FedEx continue to do so in the future? Why or why not?
Write java program that can serve as simple calculator : Write down a Java program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0.
Elucidate what are some economic conditions : Elucidate what are some economic conditions that affect the cost of money
Elucidate whether current economic conditions are more : Elucidate whether current economic conditions are more consistent with the Keynesian or classical economic theories.
Practices around information management : What is the most challenging problems often encountered when implementing more effective processes and practices around information management?
Reading literature critical for researchers : Why is reading literature critical for researchers?

Reviews

Write a Review

Computer Engineering Questions & Answers

  How may a project manager be sure

How can a project manager be sure that he or she has selected the correct metrics to assess project performances? Give three examples.

  Is there the standard for drc

I would like to ask a question about Disaster Recovery Site Certification? Is there certification for DRSC for computers and application? Is there a standard for DRC.

  Initialize the loop control variable before the program

In boy of the loop, I need to multiply the value of the loop control variable by 10 and by 100, then I want to change the value of the loop control variable in the body of loop.

  Kinds of digital and logical evidence

State some of the kinds of the digital and logical evidence, and special content data investigators may require to gather during an actual cyber-terrorism case.

  Make a stack area at 1000h

Push 10h bytes, located at data memory addresses 60000h to 6000fh, on the stack using indirect addressing. Then pop stack to memory addresses 62000h to 6200fh using indirect addressing. Load unique data into the 10h bytes in order to test the prog..

  Developing the sequential circuit

Develop a sequential circuit which can detect two or more consecutive 1's in a stream of the input bits. Specifically, if last two bits in sequence were 1, the circuit must output 1. Otherwise, it must output 0.

  Write down an application that displays a menu

Write down an application that displays a menu.

  Describe the function and purpose of each component

describe how the components are related to each other. For example, does the component you are describing depend on another to operate? Is it connected to the network physically or wirelessly.

  Developing the function to list software installed on system

Write down a function which list the software (name and vendor) installed over the computer specified by the input argument. The function should output the list to screen and output the list to the CSV file.

  Why captured in organizational standards

Discuss how standards can be used to capture organizational wisdom about efficetive methods of software development.

  How the estimated budget is as close to reality as possible

How important is it to be accurate with respect to the estimated budget and actual budget of a project.

  Explain how to compile and run a standalone java application

Write a simple Java program that incorporates as a minimum three best practices for making your code readable and understandable by yourself and others.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd