Linux Calculator in Java, Basic Computer Science

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;
}
Posted Date: 4/11/2012 8:22:03 PM | Location : United States







Related Discussions:- Linux Calculator in Java, Assignment Help, Ask Question on Linux Calculator in Java, Get Answer, Expert's Help, Linux Calculator in Java Discussions

Write discussion on Linux Calculator in Java
Your posts are moderated
Related Questions
Regardless of of the fact that a thread must execute in process, the process and its associated threads are different notion. Processes are used to group resources together and thr

Development of UNIX: The original UNIX development was performed on a Digital PDP-7 minicomputer and later moved to a PDP-11 minicomputer, the forerunner of the VAX computer.

Mini Computers and Micro Computers: The mini computers are intermediate in power, and may function as small mainframe computers. They are often dedicated to a particular purpo

solve three given number in ascending order through algorithm

Question 1 Describe the following- Binary Number System b. Octal Number System Hexadecimal Number System   Question 2 Describe the Canonical Logical Forms-

HARDWARE BASICS In the foregoing section of this Unit, an attempt has been made to explain to you the historic perspective relating to the development of computer from its ear

THE THIRD GENERATION (1966-1975) The introduction of IBM-360 series of computers in 1965 marked the beginning of this generation. The transistors were replaced by solid

Question 1 Explain any two issues in web design Question 2 Mention the factors considered for good design Question 3 What are the advantages of graphical system?

Write a half-page summary explaining IP spoofing.

Server In a network, the resources of computers comprising network are usually shareable. In fact, one of the main objectives of networking is to make the computing resources