Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

4. Understand the process of group socialization of individuals.

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago