Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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;
}

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9502185

Have any Question?


Related Questions in Computer Engineering

A summary of business activities of a course registration

A summary of business activities of a "Course Registration System" for enrolling courses for students and for enrolled class lists for faculty members at an online university is as follows: The Physics Department provide ...

Determine whether or not the following claim is true for

Determine whether or not the following claim is true for all regular expressions r 1  and r 2 . The symbol ≡ stands for equivalence regular expressions in the sense that both expressions denote the same language.  (a) (r ...

What are the tax reforms included in the train lawhow would

What are the tax reforms included in the TRAIN law? How would it impact the bottom 60% of the households and the top 40% of the households? Lastly, how does the being proposed transfer scheme works? Source: https://opini ...

What are the differences between server a mainframe and a

What are the differences between server, a mainframe, and a supercomputer? What is productively software? Name the widely used productively suite available from Microsoft?

Question identify and discuss pros and cons of the

Question: Identify and discuss pros and cons of the webrezpro service compared to a traditional PMS. Please follow the Discussion Rubric to receive credit for posts. The response must be typed, single spaced, must be in ...

Question suppose that an application has m input variables

Question : Suppose that an application has M input variables and that each variable partitions the input space into N equivalence classes. The multidimensional partitioning approach will divide the input domain into how ...

Question why most of the researchers in the field of arabic

Question : Why most of the researchers in the field of Arabic text classification collected their own corpus and what is In-house Arabic corpus. The response must be typed, single spaced, must be in times new roman font ...

Calculate the present worth of all costs for a newly

Calculate the present worth of all costs for a newly acquired machine with an initial cost of $30,000, no trade-in value, a life of 15 years, and an annual operating cost of $13,000 for the first 4 years, increasing by 1 ...

Please explain which formula i should use to complete the

Please explain which formula I should use to complete the following probability question: The probability that a family will buy a vacation home in Miami, malibu, or newport is 0.25, 0.10 and 0.35. What is the probabilit ...

Has globalizationnbspincreased or decreased social and

Has globalization increased or decreased social and economic disparities around the globe? Can you please provide details.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As