The purpose of this assignment is to gain experience with basic function definit
ID: 3916091 • Letter: T
Question
The purpose of this assignment is to gain experience with basic function definitions, function calls and using data files for input/output. Please see the HINT document before starting on programming. ASSIGNMENT REQUIREMENTS ( Design three different functions) Build a command-line C++ application that allows user to convert pre-recorded temperature values from Fahrenheit to Celsius or from Celsius to Fahrenheit. Related data is provided along with this assignment. Once completed, the user will be prompted by three options: . Option 1 Convert Celsius to Fahrenheit in menu Option 2 Convert Fahrenheit to Celsius Option 3 Exit Any other entry must result in a warning message (Invalid Entry). User will be asked choose one of the listed options again. Program will not stop unless Option 3 is selected. IF OPTION 1 IS SELECTED: 1. User will be prompted by "Celsius to Fahrenheit process is initiated" 2. Then program reads temperatures in degrees Celsius from the given input file (data Celsius.txt), calls the function (myc2f) to convert the temperature to degrees Fahrenheit, and write the converted temperatures into an output file named as LastName Fahrenheit Output.txt) 3. Then, program will produce a confirmation message on the screen "Celsius to Fahrenheit process is completed 4. Then ask user to choose from remaining options (i.e. Option 2, Option 3). Get the user's entry, and then clear the screen. IF OPTION 2 IS SELECTED: 1. User will be prompted by "Fahrenheit to Celsius process is initiated" 2. Then program reads temperatures in degrees Fahrenheit from an input file (data_Fahrenheit.txt), calls the function (myf2c) to convert the temperature to EGR 126 degrees Celsius, and write the converted temperature into an output file named as (LastName Celsius Output.txt) process is completed" entry, and then clear the screen. 3. Program will produce a confirmation message on the screen "Fahrenheit to Celsius 4. Then ask user to choose from remaining options (i.e. Option 1, Option 3). Get the user's IF OPTION 3 IS SELECTED: 1. User will prompted by "Exit from the program 2. Exit from the program. Program will notstop unless "Option 3" is selected. EXPECTATIONS You will submit one C++source code document which will generate two output data files based on the user's choice. You do NOT need to submit the input data files. Use the input data files (named data Celsius.txt and data Fahrenheit.txt), provided with the assignment, to test your code. A minimum of 3 functions must be designed. Optionally, you may design additional functions, for example, to display error messages. The three required functions are: 1. A void function to display the MAIN MENU 2. myc2f ) to Convert Celsius to Fahrenheit 3. myf2c ) to Convert Fahrenheit to CelsiusExplanation / Answer
A command line application allows the user to input their values dynamically.The user can enter the required inputs during the execution of the program.To give command line inputs,the values has to be passed in the command line itself as the strings such as args[0],args[1],args[2] and so on..where args[0] holds the first value and args[1] holds the second value and so on..For the above program switch case is to be used to give the user various option to choose.
Two precorded files are : data_Celsius.txt and data_Farenheit.txt //from where the input has to be taken
These files has to be imported to the main file.
using namespace std;
float myc2f(float c) //function to convert celsius to farenheit
{
float f;
f = (c * 9.0) / 5.0 + 32;
return f;
}
float myf2c(float f1) //function to convert farenheit to celsius
{
float c1;
return c1;
}
void main()
{
cout<<"Main Menu"<<endl;
cout<<"1.Convert Celsius to Farenheit"<<endl;
cout<<"2.Convert Farenheit to Celsius"<<endl;
cout<<"3.Exit<<endl;
cout<<"Select any of the above options 1/2/3"<<endl;
string n=args[0];;
do
{
switch (n)
float ans;
cout<<"Celsius to farenheit process is initiated"<<endl;
ans=myc2f(data);
return 0;
cout<<"celsius to farenheit process is completed"<<endl;
float ans1;
cout<<"Farenheit to celsius process is initiated"<<endl;
ans1=myf2c(data1);
return 0;
cout<<"farenheit to celsius process is completed"<<endl;
clrscr();
}while(n!="3");
if(n=="3")
{
cout<<"Exit from the program"<<endl;
exit(0);
break;
}
getch();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.