Question
Use the following prototype for your tempconvertor function. DO NOT CHANGE ANYTHING IN THE PROTOTYPE. double tempconvertor(double, double&); Function Objective Write a function that takes
Use the following prototype for your tempconvertor function. DO NOT CHANGE ANYTHING IN THE PROTOTYPE.
double tempconvertor(double, double&);
Function
Objective
Write a
function
that
takes a temperature in Kelvin as input and returns that
temperature in
Fahrenheit and
Celsius.
Since any function can have only
one return
value, your function will return the second temperature using a call by reference formal
parameter.
Function
Specifications
-
You
r
function
must have the name
tempconvertor
(
NOTE THE SPELLING)
-
You
r
function
must have two formal parameters, each
of type double
-
The first parameter is the temperature in Kelvin and must be passed by value
-
The second parameter is the temperature in Celsius and must be passed by
reference
-
The return type for your function must be double
-
The return value for your functi
on must be the temperature in Fahrenheit
-
Since zero Kelvin is the lowest possible temperature, your function must set both
the Celsius and Fahrenheit temperatures to
-
1000 for a Kelvin temperature less
than zero
-
For all Kelvin temperatures greater than or
equal to zero, your function must
convert the Kelvin temperature to Celsius and
Fahrenheit
using the following
equations
Celsius = Kelvin
273.15
Fa
h
renheit =
Kelvin X (9/5)
459.67
I
n your Vocareum
work directory you will find two files.
Do not delete or rename either
of these files.
One file is named Assignment8_function.cpp. You must write your
tempconvertor
function
definition
(and only your function definition) in this file.
The second file is called Assignment8_main.cpp. In this fi
le you should write a
main
function with which you can test your
tempconvertor
function. For example, your
main
function could ask the user to enter a temperature in Kelvin, then call the
function
tempconvertor
, and then display the temperature in Kelvin,
Celsius, and
Fahrenheit.
Writing an appropriate
main
function
in the file Assignment8_main.cpp
is
the
only
way to test your
tempconvertor
function.
Note
: The correct prototype for your function is given in the starter code in the file
Assignment8_main.cpp.
DO NOT CHANGE THE PROTOTYPE GIVEN
. Place this given
prototype above the main function you will write in
Assignment8_main.cpp.
Note
: Only your
tempconvertor
function will be graded. Your
main
function will
NOT be graded. Therefore, you
may
write your
main
function any way you wish.
Note
: When you click Build or Run in Vocareum
, your code in both
Assignment8_function.cpp and Assignment8_main.cpp will be linked
together and
compiled (and then executed if you clicked Run). If your Assignment8_main.cpp file is
empty, you can still compile the code in Assignment8_function.cpp by cli
cking Build.
However, you cannot Run just the code in Assignment8_function.cpp.
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