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

  Squashes the difference in fruit weight-distribution

Assume that in squashes the difference in fruit weight between a 3-lb type and a 6-lb type results from three independently segregating allelic pairs, A/a, B/b, and C/c. Each capital-letter allele contributes a half pound to the weight of the squash...

  Calculate the additional amount of sales

Calculate the additional amount of sales that each salesperson must achieve to match or exceed the higher of the two earners - The application should ask for the name of each salesperson being compared.

  Project amount of total sales

Write a program called sales_prediction.js, that displays the profit based on the project amount of total sales for the year. Use a literal value of $2,500,000 for the projected total sales amount. Display the profit amount formatted to two decima..

  Calculator to indicate sale prices when he marks items down

A retailer would like a calculator to indicate sale prices when he marks items down at various percentages.

  Develop an app which allows users to keep records

ICT311 - Mobile App Development - report explaining the design of the app. Submit your code via GitHub or BitBucket, and your report to Blackboard Task 2. Please follow the submission instructions on Blackboard.

  C program in unix environment

This question deals with writing a C Program in UNIX environment (bash). You must rewrite the LS system call in C, but the output of files MUST be in decreasing order in the size of the file (bytes).

  Implement 1-parameter date constructor that receives string

Date objects should store the date in two int instance variables: day and month, and it should include the String instance variable, error, initialized with null.

  Write a statement that prints the number of characters

Write a statement that prints the number of characters in a String object called myString. Write statements to prompt for and read user's age using Scanner variable

  Create the program which converts fahrenheit to celsius

Create the following program which converts Fahrenheit to Celsius. Read integer Fahrenheit temperatures from the user.

  Displays the calendar for the current month

Prepare a program that displays the calendar for the current month. You will use the Prior and next buttons to show the calendar of the previous or next month.

  Calculate the new date by adding a fixed number of days

What I have done is the "ExtendedDate.java", which improved the "data.java" that the program will firstly check if the date input from users is valid then store it with the setDate method.

  Number of primes

Write a program BackwardPrimes.java that prompts user for a positive integer number x and displays x prime numbers whose reversal is also a prime. Numbers 13, 31 and 157 are instances of such numbers. Following is a sample run of your program.

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