Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program that runs on ocelot for a mini calculator using only the command line options. You must use getopt to parse the

Write a C program that runs on ocelot for a mini calculator using only the command line options. You must use getopt to parse the command line. The calculator will only do addition, multiplication and a power of 2.

Usage: minicalc [-a num] [-m num] [-x] value

The variable value is the starting value.

Value should be validated to be an integer between 1 and 50 inclusive. Error message and usage shown if not.

For the -m option num should be a positive integer between 1 and 10 inclusive.

For the -a option num should be a positive integer between 1 and 500 inclusive.

-a adds num to value. -m multiplies value by num. -x squares value. (Note: no num is needed.)

Output should have exactly 2 decimal places no matter what the starting values are.

If -x is included, it is executed first. If -m is included it would be next. The -a would be executed last.

There will be at most one of each option, if there are more than one you can use either of the options in the calculation.

There should be no user input while the program is running. It runs in full from the command line. Create a simple Makefile to compile your program into an executable called minicalc.

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

8. Praise the trainees for their success in learning the task.

Answered: 1 week ago