hey, im close to finishing this code, but im sick and cant focus well, can someo
ID: 3651677 • Letter: H
Question
hey, im close to finishing this code, but im sick and cant focus well, can someone help me so its clean again?This code should solve---
This program is to give the user the option of converting a set of temperatures either from Celsius to Fahrenheit (C to F) or vice versa, from Fahrenheit to Celsius (F to C), or to quit the program. If the user selects either C to F or F to C, the program will prompt the user to enter three integer values, a starting temperature, an ending temperature, and an increment. After these values have been entered the program will display a table of equivalent C and F (or F and C) temperatures, from the starting temperature to the ending temperature and incrementing by the increment value each row.
here is what i got guyz so far.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
float CtoF(float start ,float increment)
{
float f=0;
f=(9*start/5)+32;
return f;
}
float FtoC (float start, float increment)
{
float c = 0;
c = (5/9) * (start-32);
return c;
}
void displaymenu()
{
cout << " !!!!!!!!!Menu!!!!!!!!"<<endl;
cout << "Please enter one of the following please" << endl;
cout << "'C' for celcius to farenheit(C to F)" << endl;
cout << "'F' for farenheit to celcius(F to C)" << endl;
cout << " Or to Exit the program 'Q'" << endl;
}
char getMenuSelection()
{
char choice;
do{
cout<<"Enter your choice"<<endl;
cin>>choice;
switch(choice)
{
case 'c':
case 'C':return choice;break;
case 'f':
case 'F':return choice;break;
case 'q':
case 'Q':exit(0);
default :cout<<"Please choose between the three choices above. "<<endl;
}
}while(1);
}
void getStartEndIncrement(float start,float end, float increment)
{
cout<<"Enter stat temperature:"<<endl;
cin>> start;
cout<<"Enter end temperature:"<<endl;
cin>> end;
cout<<"Enter increment value:"<<endl;
cin>> increment;
}
void displayTable(float start,int increment,float result)
{
double i;
for(i=start;i<=end;i=i+increment)
{
cout<<setw(10)<<i<<(char)248;
switch(result)
{
case 'f':
case 'F':
cout<<setw(10)<<FToC(i)<<(char) 248<<endl;
break;
case 'c':
case 'C':
cout<<setw(10)<<CToF(i)<<(char) 248<<endl;
}
}
cout<<endl;
system("pause");
}
int main()
{
float start, end, increment;
do{
displaymenu();
char ch= getMenuSelection();
switch(ch)
{
case 'f':
case 'F': system("cls");
getStartEndAndIncrement(start,end,increment);
cout<<" "<<setw(10)<<(char) 248 <<"F"<<setw(10)<<(char) 248<<"C"<<endl<<endl;
displayTable(start,end,increment,ch);
break;
case 'c':
case 'C': system("cls");
getStartEndAndIncrement(start,end,increment);
cout<<" "<<setw(10)<<(char) 248 <<"C"<<setw(10)<<(char) 248<<"F"<<endl<<endl;
displayTable(start,end,increment,ch);
break;
case 'q':
case 'Q': exit(0);
}}while(1);
return 0;
}
Explanation / Answer
almost everything is corect is corect in that
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.