Question
PLEASE WRITE THIS IN C PROGRAMMING LANGUAGE. NOT C++ You are required to design a calculator. This calculator reads commands from data files called CommandsProj1.dat
PLEASE WRITE THIS IN C PROGRAMMING LANGUAGE. NOT C++
You are required to design a calculator. This calculator reads commands from data files called CommandsProj1.dat and CommandsProj2.dat, which will be available from the class website. Your program should read the commands in sequential order, process them, perform the necessary calculations, and then print out the results in a neat, readable manner, both to a file and to the screen.
Details:
The first line of the file contains two characters giving the initials of the user (such as GN). The rest of the file consists of a sequence of commands. Each line of the command file contains one command. Each command starts with a character and may have zero or more operands. You may assume that the data file has no errors. The number of commands in the file is unknown. But your processing may stop as soon as the Quit command is processed. The commands are: integer add, integer subtract, integer multiply, integer divide, change to uppercase, change to lowercase, separate, print out all digits, print out the k-th digit, round real number to desired number of decimal places, divide number into two.
Calculator Commands:
+ i j [Integer Add]
| Add integers i and j and print out result |
* i j [Integer Multiply]
| Multiply integers i and j and print out result |
- i j [Integer Subtract ]
| Subtract integer j from i and print out result |
/ i j [Integer Divide ] | Divide integer i by j and print out result of integer division |
C Ch [Character Case Change ] Change character Ch to uppercase and print it out
c Ch [Character Case Change] Change character Ch to lowercase and print it out
P i k [Print k-th Digit ]
| Print out the k-th digit of integer i |
R x i [Round Reals ]
| Round double value x to i decimal places |
S x [Separate ]
| Separate out the sign, integer part and fractional part of double value x |
H [Help ]
| Print a short synopsis of all the available commands |
Q [Quit ]
| Quit |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started