Create a function EnergyConversion.m which takes two input arguments, E and units and returns one output argument, C which is the conversion of E from Joules to the new energy unit units according to the table. Use the following definition line function [C] = EnergyConversion (E, units) PM E The input arguments must be a scalar numeric variable E and a character string units. The output argument must be a scalar numeric variable C. You must use a switch- case structure and call the error function if the new units are not recognized. All string comparisons must be case-sensitive so that, for example, "ev" and "btu" ARE NOT recognized but "eV" and "BTU" ARE recognized as valid unit conversions.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 1TF: Mark the following statements as true or false: a. To use a predefined function in a program, you...
icon
Related questions
Question
Help
4. Create a function EnergyConversion.m which takes two input arguments, E and
units and returns one output argument, C which is the conversion of B from Joules to
the new energy unit units according to the table. Use the following definition line
function [C] = Energy Conversion (E, units)
The input arguments must be a scalar numeric variable E and a character string units.
The output argument must be a scalar numeric variable C. You must use a switch-
case structure and call the error function if the new units are not recognized. All string
comparisons must be case-sensitive so that, for example, "ev" and "btu" ARE NOT
recognized but "eV" and "BTU" ARE recognized as valid unit conversions.
Unit
1 cal
1 BTU
1 kWh
1 eV
Conversion
4186 J
1055.06 J
3.6x106 J
1.602x10-19 J
haracto PM EDT
7:38:3
Transcribed Image Text:4. Create a function EnergyConversion.m which takes two input arguments, E and units and returns one output argument, C which is the conversion of B from Joules to the new energy unit units according to the table. Use the following definition line function [C] = Energy Conversion (E, units) The input arguments must be a scalar numeric variable E and a character string units. The output argument must be a scalar numeric variable C. You must use a switch- case structure and call the error function if the new units are not recognized. All string comparisons must be case-sensitive so that, for example, "ev" and "btu" ARE NOT recognized but "eV" and "BTU" ARE recognized as valid unit conversions. Unit 1 cal 1 BTU 1 kWh 1 eV Conversion 4186 J 1055.06 J 3.6x106 J 1.602x10-19 J haracto PM EDT 7:38:3
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning