Linux Calculator in Java, Basic Computer Science

Assignment Help:
Hello,
Could you create a linux calculator using very basic java code (not complex, because I am a novice java coder). It should be called into the terminal for interaction.
Thank You!!
Here is the assignment:

I have a problem performing simple arithmetic operations. I need it to
perform addition, subtraction, multiplication, division, and exponentiation.
The program should read operations from standard input and/or from a file. If it reads from a file then the file will contain all of the operations and data. If the program reads from standard input then the program is interactive. It should be able to do both.
The program is to be called xcalc. It is to be run from the UNIX command line prompt. A sample execution is below.

$calc file l file 2
$calc < file 1
$calc
It will read from the standard input and write to the standard output with the capability of i/o redirection. I also want the program to have the command line option capability to specify an output file
Scale -O outputfilename inputfilenamel
The numbers read are to be unsigned integers and the operations are to be in prefix form. The operations are addition, subtraction, multiplication, division, and exponentiation.

The control d character (the UNIX end of file character) will end the program if it is interactive. The following sample list of operations should help clear up any confusion.

"+11 11"

"-22 11"
"*22 2"
"/22 2"

"e 2 3"


The operation must be the very first character on the input line followed by 1 or more blanks. Any number of blanks can be before or after each operand. No blanks can be embedded into a number. Sample execution and operation follows that illustrate interactive mode
$xcalc
>>+ 11 22
>>11 + 22 =33
>>*22 2
>>22 * 2 = 44
>>

There is one arithmetic operation that can be used to implement all others. Determine which one and use it to implement all of the operations: "+, -, *, /, and e." If you cannot determine which operation is the "one magical all powerful operation" then try using addition "+".
You should check for invalid operations and for division by zero.
This program is to be developed using the principles discussed in class
Each operation should be implemented as a function. See the example below.

int add (int augend, int addend)
{
int sum;
sum = augend + addend;

return sum;
}
If you cannot figure out how to use addition "+" then use the : "+, -, *, /, and e." in a straight forward manner.
int multiply (int multiplicand, int multiplier)
{
int product;
product = multiplicand * multiplier;

return product;
}

Related Discussions:- Linux Calculator in Java

Describe four types of abstracts, QUESTION 1 Write short notes on cont...

QUESTION 1 Write short notes on controlled vocabulary indexing. QUESTION 2 (a) List five types of abstracts. (b) Describe four types of abstracts. QUESTION 3

Logic and arithmetic functions, The instructions of the logic functions are...

The instructions of the logic functions are: and not, or and xor. These act on the bits of their operators. To make sure the result of the operations we revolve to the cmp and test

Discuss the roles of system analysts in detail, Question 1 Explain the ...

Question 1 Explain the following system design tools in detail System Flowcharts Decision tables Decision trees Organization charts Question 2 Write s

Computer system architecture, 1. Suppose that the meaning of the BUN instru...

1. Suppose that the meaning of the BUN instruction of the Basic Computer is changed to implement the relative addressing mode, i.e PC a) Write an optimal operation sequence to im

471, #que411stion..

#que411stion..

C, board coloring

board coloring

Explain master slave j-k flip flop, Question 1 Convert the following binar...

Question 1 Convert the following binary numbers to its specified number system 1101.11 (2) to octal 1111 (2) to decimal 110.11 (2) to hexadecimal 1011.11 (2) to

Describe circuit switching and message switching, Question 1 List the Basi...

Question 1 List the Basic essential components of a computer network Question 2 What are the functions of (i) Routers (ii) Bridges Question 3 What are the advantag

Write Your Message!

Captcha
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