Modify the java source code file calculator

Assignment Help JAVA Programming
Reference no: EM131374131

Java - Calculator

General description for homework: In this homework, you need to modify the java source code file Calculator.java in chap 9, so that it takes the input parameter in a different way. For example, instead of taking one parameter "7 + 20" as the only argument, the modified version takes three parameters 7 + 20 as the argument list for the main method, and perform the same task of calculating the result for the expression. Here is the detail description for homework 9: No GUI is needed in this homework. No console input is needed, thus no need to import Scanner class. In the main method, then follow the STEPS below:

1. If the number of arguments supplied to the main method is not equal to 3, then output a line that says "Usage: java operand1 operator operand2" , and then quit the program. The program continues to the following steps if the argument number is 3.

2. If the second parameter is none of the following: + , -, x, / , %, then you need to output a line that says: "supported operators are +, -, x, / , and % " , and then quit the program. The symbol x above means multiplication. Attention: we CANNOT use symbol * as multiplication in our homework, and the reason is explained in the "Implementation requirement" below.

3. If the second parameter is any one of the following: + , -, x, / , %, then convert the first and the third parameter to int type, and then perform the required calculation. Save the calculated result to a local variable, and the result should be of int type.

4. Output to the console with the entire expression and calculated result , such as 7 + 20 = 27 Implementation requirement:

• In class java, you should have only one method: the main method. Do not put more classes or more methods in the homework, o/w, you are in the wrong track.

• User Calculator.java as a reference, and feel free to invoke APIs from String/StringBuilder.

• Notice that if the operator is / , and the result is int type, that means the division precision will not be kept. For example, 13 /3 will yield a result of 4.

• Notice that we use symbol x for multiplication operation, and this is different from textbook source code "Calculator.java" that uses symbol * for multiplication. We CANNOT use symbol * for multiplication in this homework, because symbol * has special meaning in command line, when symbol * itself is supplied as an individual String object in the command line.

• Symbol % means the remainder operator, and you can refer to textbook page 46 for explanation of remainder operator.

• Add suitable comments in the source code.

• Please read the above implementation details carefully BEFORE start coding.

• After finishing coding, you need to debug your program and test it multiple times with different input parameters provided for each test run.

• You can use command line to supply the arguments and test the program, or use Eclipse. Either way is fine.

Reference no: EM131374131

Questions Cloud

What should you do in the given scenario : You expect the yen to rise from its present rate of $1 = ¥130 to $1 = ¥100 by December. You can borrow yen at 6 percent a year. What should you do?
What smoke spot number represents correct combustion : Discuss the relationship between the over-fire draft and the stack draft.
What was the nature and significance of this debt : You are at a cocktail party of math teachers trying to impress your professors. Responses should be 300-500 words and include a citations. What was the nature and significance of this debt? What were some of the conditions that made it possible
Describe the procedure for purging a two-pipe system : What can cause the heat exchanger flow resistance to increase after several years of operation?
Modify the java source code file calculator : General description for homework: In this homework, you need to modify the java source code file Calculator.java in chap 9, so that it takes the input parameter in a different way.
What is the overall message of thoreau''s solitude : What is the overall message of Thoreau's "Solitude"? Consider the term epiphany, which is a moment of clarity and understanding.  Is there such a moment in this essay?  If so, what triggers it
What is the heating value of grade 2 fuel oil : What voltage does the ignition transformer provide to the electrodes?
Evaluate the benefits and costs and risks associated : Evaluate the benefits, costs, and risks associated with doing business in each nation. Which country seems the most attractive target for foreign direct investment? Why?
What are the impediments to completing the transformation : What kind of economic system did India operate under during 1947-1990? What kind of system is it moving toward today? What are the impediments to completing this transformation?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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