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

  What are some more popular methods utilizing string class

What are some of the more popular methods utilizing the "String" class? Show examples of their usage. Java gives us the ability to do output to the console screen in many ways. What is the difference between printing and printf? Show an example of ..

  Modify the java application using netbeans ide

Modify the Java application using NetBeans IDE to meet these additional and changed business requirements:  The application will now compare the total annual compensation of at least two salespersons

  What are the concerns about how java implements arrays

What are the concerns about how Java implements arrays? What are your concerns? In Java, what is the starting index of an array

  Why does tomcats first servlet request take so long

Why does Tomcat's first servlet request take so long? How do I disable port 8080? I want Tomcat to run only through my Web server, not directly through Tomcat.

  Write a method named rowofstars

Write a method named rowOfStars that takes a single integer parameter n and returns a String with that many stars in it.

  Write a java class that creates an array of integers

Write a Java class that creates an array of integers, fills it with values, prints the unsorted values, sorts the values into ascending order, and finally prints the sorted values.

  Benefits of using java as a programming language

What are the benefits of using Java as a programming language? Discuss how the use of an integrated development environment (IDE) such as Eclipse enhances programmer productivity

  Calculate your age in the year 2060.

Declare and initialize an integer variable named currentYear. Initialize this variable with the value of the currentYear. Use four digits for year. Use four digits for the year.

  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.

  Write program that prints all solutions to n queens problem

write a program that finds and prints all the solutions to the N queens problem for a given N. At the end of your program, print how many solutions were found. What is the N-Queens problem, you ask?

  Concurrent access to objects

This question asks about synchronizing methods for stack and queue objects. (a) Bounded stacks can be de?ned as objects, each containing an array of up to n items. Here is apseudocode for one form of stack class.

  Debug a program with a jframe

Design, implement, test, and debug a program with a JFrame that allows the user to enter a series of contacts' names, ages, e-mail addresses, and cell phone numbers, and creates a file from the entered data

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