Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a c code This program gets its input from the command line... but this time, we will be using argv [1], argv [2] and

write a c code
image text in transcribed
image text in transcribed
This program gets its input from the command line... but this time, we will be using argv [1], argv [2] and argv [3]. It really is easier and more reliable than scanf(). The goal of this lab is to convert a value from one unit of energy to another. The units of eneray we will convert are: Usage: catPower fromValue fromUnit toUnit fromvalue: A number that we want to convert fromunit: The energy unit fromvalue is in toUnit: The energy unit to convert to If the program is run with anything other 3 valid arguments, then print the full usage statement (see sample below). If the program is run with 3 valid arguments, print the conversion as: fromValue fromUnit is toValue toUnit A test vector is: To compile the program: $g++-o catPower -Wall catPower.cpp A few tips: - Map fromvalue to a commonValue (it can be Joules or anything other than catPower). Then, map from a commonValue to a toValue. - Use functions (with parameters) to do all of the mapping. - I've given you a template of a switch \{ I statement to use. You'll need to write another one to map commonValue to the unit you are converting to. - There were two reading assignments about testing... $. /eatpower Catpower Usage: catpower fromvalue fromUnit tonit fromvalue: A number that we want to convert frombnit: The energy unit fromvalue is in tounit: The energy unit to convert to This progran converts energy from one energy unit to another. The units it can convert are: j= Joule e =eV= electronvolt m=MT= megaton of TNT g=GGE= gasoline gallon equivalent f=foe= the amount of energy produced by a supernova c= eatpower =11ke horsepower, but for cats To convert from one energy unit to another, enter a number it's unit and then a unit to convert it to. For example, to convert 100 Joules to GGE, you'd enter: $ catPower 100jg $. /catpower 2je 2j is 1,2483E+19

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

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

=+3. What are the components of a social media communication audit?

Answered: 1 week ago