Answered step by step
Verified Expert Solution
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
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
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