Write a java program that can serve as a simple calculator.

Assignment Help JAVA Programming
Reference no: EM13940750

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: EM13940750

Questions Cloud

Explore the resources and capabilitiestopic area : You need to explore the Resources and Capabilitiestopic area discussing theoretical concepts within the area and look at how Canon's strategy can be understood by drawing on ideas from the literature. You are of course permitted to draw on other a..
Unions tend to disavow their usefulness : While performance evaluations are part of most organizations, unions tend to disavow their usefulness. Are performance evaluations needed in a union environment?
Dealing with the blood diamonds issue : Evaluate DeBeers' choice of strategy in dealing with the blood diamonds issue (Hint:use the criteria of suitability, acceptability and feasibility (Johnson et al, 2011, p.364ff), bearing in mind that this was not simply a financial decision)
What are your reservations about staff reduction efforts : What are your reservations about staff reduction efforts? What can a manager, do to become more confident in facing reduction in workforce issues?
Write a java program that can serve as a simple calculator. : 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.
Explain specifics about penalties that led to your opinion : Explain the specifics about the penalties that led to your opinion. In addition, explain whether you think most policies in the system have the goal of:- Using punishment or threat of punishment to deter people from committing crime.
Break-even chart to illustrate this solution : Each additional unit a company produces costs £45 to manufacture and it can sell each unit it produces for a fixed price of £72. The firm also has fixed costs of £8,100.
Show with a diagram the cash flows in this given deal : Show, with a diagram, the cash flows in this deal, assuming no Early Buyout Option. Would the deal make sense for DEF Leasing, assuming that its shareholders insist on a required return on equity of 15% p.a.
Steps in market research process : List the four steps in market research process? Describe in some detail the three types of research that are typically used in a business environment and any specify areas of research interest to business?

Reviews

Write a Review

JAVA Programming Questions & Answers

  How many states are there and draw and label the states

How many states are there and draw and label the states (with variable values) and transitions (with method names). Notice that all of the methods are total.

  Java program to implement currency converter

Write a JAVA program that helps the user convert currency. The user will enter the amount in Kuwaiti dinars. The program will print the equivalent amount in US dollar and Euros count his change.

  Write a java gui application index2 java

Write a Java GUI application Index2.java based on the program in Step 1 that inputs several lines of text and uses String method indexOf to determine the total number of occurrences of each letter of the alphabet in the text

  Write a java applet for grade of gas in costco gas station

Write a java applet (not a java application program) for costco gas station. The applet will first ask you whether you are a costco customer, then the grade of gas you want to use.

  Write code that will save data to a file

The user will enter a Drexel course code. The course code beings with two capital letters, followed by an optional hyphen, followed by 3 digits, and followed by an optional section number

  Java application prompt user to put in integer from keyboard

Write a java application that performs the following task: prompt user to put in an integer from the keyboard, search for the user input from the array created in step 1.

  Use a gui interface to control and display result of program

The scenario is inspired by a Library Management System (LIMS). For the first version of the project, the LIMS is a very basic one, allowing just for the import of data from a text file and perfom some basic search operations.

  Process of buying a soda from a soda machine

Please write a Java Program those steps through the process of buying a soda from a Soda Machine.  You must interact with the consumer. Each Soda is one dollar.

  Display the program output of the collision results

According to my lecturer, I need the tutor to display the 'program output' of the collision results implemented by BirthdayAttack.java in a output.txt file. Can the tutor do this?

  Write down java program for furniture company

Write down a Java program for the furniture company. Ask user to select P for Pine, O for Oak or M for Mahogany. Illustrate price of table manufactured with chosen wood.

  Write java dice program

write java dice program.

  Converting pseudocode to javascript

I would need help in converting converting pseudocode to JavaScript. I already have the pseudocode in a html file but need it to be converted to JavaScript and run like it should.

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