Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, below is a Lab we are doing, these are in preperation for our projects. Could someone please complete what is below, I am new

Hello, below is a Lab we are doing, these are in preperation for our projects. Could someone please complete what is below, I am new to coding and am having a very ahrd time figuring this one out. Thanks

Lab 7

For this second lab on functions we once again work on writing a series of functions that can then be used by a larger function. In this case we are going to be write several conversion functions for converting between several different kinds of measures. Then we will write a controller function that will allow us to script the use of our converter functions.

Details

For this lab, you will write 8 functions that will need to follow the signatures that are given below. I will be testing your code by both calling these functions directly and using the main conversions function that will allow us to script the other functions.

void fromSeconds( int time, int& minutes, int& seconds); int toSeconds( int hours, int minutes, int seconds ); double toCelsius( double degrees ); double toFahrenheit( double degress ); double toInches( double centimeters ); double toCentimeters( double inches ); double toMiles( double kilometers ); double toKilometers( double miles ); 

These are the 8 conversion functions. They must be written as shown, i.e. I will be calling these function explicitly and if you dont follow their signatures, your code will not compile and youll get a bad grade.

Additionally, youll need to write the function below, that will allow for scripting of those functions.

void conversions( string input, string output ); 

I encourage, but am not requiring, the use of the following constants to help in the conversions.

const double CTOF = 5.0/9.0; const double FTOC = 9.0/5.0; const double CTOI = 2.54; const double KTOM = 1.609344; 

Ill be explaining each of the 8 functions that are shown above here:

fromSeconds - this function takes as input an integer that represents a time in seconds, you are to take that given time and compute the number of minutes and seconds. You will use the pass-by-reference parameters, minutes and seconds to give back the two answers.

toSeconds - this will take the 3 parameters, hours, minutes, and seconds, and return the total time in seconds.

toCelsius - this will take the given temperature in Celsius, and return the corresponding temperature in Fahrenheit.

toFahrenheit - this will take the given temperature in Fahrenheit, and return the corresponding temperature in Celsius.

toInches - this will take the given measurement, in centimeters, and return the corresponding measurement in inches.

toCentimeters - this will take the given measurement, in inches, and return the corresponding measurement in centimeters

toMiles - this will take the given distance, in kilometers, and return the corresponding distance in miles.

toKilomoeters - this will take the given distance, in miles, and return the corresponding distance in kilometers.

The constants Im encouraging you to use are used in the conversions and are the constant factors you need.

The final function is the main function that will allow for an input file to control which functions are used. It will understand the following set of commands:

to-seconds 4:50:06

from-seconds 654

to-Celsius 68.4

to-Fahrenheit 23.4

to-inches 23.1

to-centimeters 45.2

to-miles 5

to-kilometers 3.1

Each of the commands will be followed by an argument. The ones that are above are example arguments. They show the format of the argument for the command. For example, to-seconds will be followed by a time in hour:minute:second form and the hours and minutes and minutes and seconds will be separated with a colon (:). The rest of the arguments are simply double numbers.

Input

to-seconds 4:50:06 from-seconds 654 to-Celsius 68.4 to-Fahrenheit 23.4 to-inches 23.1 to-centimeters 45.2 to-miles 5 to-kilometers 3.1 

The input is simply the command followed by the argument. If this is the input, then the output will be shown below.

Output

Heres the corresponding output for the given input:

Command: to-seconds 4 50 6 17406 Command: from-seconds 654 10:54 Command: to-Celsius 68.4 20.2222 Command: to-Fahrenheit 23.4 74.12 Command: to-inches 23.1 9.09449 Command: to-centimeters 45.2 114.808 Command: to-miles 5 3.10686 Command: to-kilometers 3.1 4.98897 

Each line of output will start with the word Command: followed by the command, the argument and then the result of the command. In the case of the fromSeconds, the output is shown as minutes:seconds. The precision of the decimals is the default precision. Do not use setprecision to adjust them.

Requirements

Heres a list of requirements

All of the functions shown above must be declared in a file name: lab7.h

You must implement the functions in a cpp file. Do not implement the code in the header.

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

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions