Celcius to Farenhiet_Table Display

Program is supposed to convert celcius to farenhiet or vice versa, then display a start and end temperature with conversions and original entries. There is an increment our prof had us add, but I don't see any reason for having it; and it is not included in the mathematical equations. This is supposed to use user defined functions and display on a table. This is what I have and keep getting an invalid null pointer message. Here's what I have:

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>

using namespace std;

void CtoF(double& stcls, double& stfrn, double& ndcls, double& ndfrn);
void FtoC(double& stcls, double& stfrn, double& ndcls, double& ndfrn);
void displayMenu(char& selc);
char getMenuSelection(char& temp);
string displayTable(string tableType, char selc);

int main()
{
double outp1, outp2;
double start;
double end;
int inc;
char x;
string tableType;

do
{
do
{
displayMenu(x);
getMenuSelection(x);

if (cin.fail())
{
cin.clear();
cin.ignore(50, '\n');
}

if (x != 'q' || x != 'Q')
{
cout << "\nEnter starting temperature:" << endl;
cin >> start;
cout << "\nEnter ending temperature:" << endl;
cin >> end;
cout << "\nEnter increment:" << endl;
cin >> inc;

if (x == 'f' || x == 'F')
{
FtoC(outp1, start, outp2, end);

displayTable(tableType, x);

cout << right << setw(4) << x << right << setw(8) << start << right << setw(10) << end << right << setw(10)
<< inc << right << setw(10) << outp1 << "°C " << right << setw(5) << outp2 << "°C " << endl;
}
else if(x == 'c' || x== 'C')
{
CtoF(outp1, start, outp2, end);

displayTable(tableType, x);

cout << right << setw(4) << x << right << setw(8) << start << right << setw(10) << end << right << setw(10)
<< inc << right << setw(10) << outp1 << "°F" << right << setw(5) << outp2 << "°F" << endl;
}
}
}
while (x != 'c' || x != 'C' || x != 'f' || x != 'F' || x != 'q' || x != 'Q');
}while (x != 'q' || x == 'Q');

cout << "Press Enter key to close window." << endl;
cin.ignore(2);

return 0;
}

void CtoF(double& stfrn, double& stcls, double& ndfrn, double& ndcls)
{
stfrn = stcls * 9/5 +32;
ndfrn = ndcls * 9/5 +32;
}

void FtoC(double& stcls, double& stfrn, double& ndcls, double& ndfrn)
{
stcls = (stfrn - 32) * 5/9;
ndcls = (ndfrn - 32) * 5/9;
}

void displayMenu(char& selc)
{
cout << "Incremented Conversion Program" << endl;
cout << "Input the letter F for Farenhiet" << endl;
cout << "Input the letter C for Celcius" << endl;
cout << "Or Input the letter Q to quit the Program." << endl;
cout << "\nWhat would you like converted, Celcius or Farenhiet?" << endl;
cin >> selc;
}

char getMenuSelection(char& temp)
{
switch (temp)
{
case 'c':
case 'C':
cout << "You will convert Celcius to Farenhiet" << endl;
break;

case 'f':
case 'F':
cout << "You will convert Farenhiet to Celcius" << endl;
break;

case 'q':
case 'Q':
cout << "Program Terminated." << endl;
break;

default:
cout << "Improper Input, please select one of the following options: C, F, or Q." << endl;
}
return 0;
}

string displayTable(string tableType, char selc)
{
if (selc =='c' || 'C')
{
tableType = " C to F ";
}
else if (selc =='f' || 'F')
{
tableType = " F to C ";
}
cout << tableType << endl;
cout << setw(26) << "INPUTS" << setw(27) << "OUTPUTS" << endl;
cout << left << "Main" << " " << "Start" << " " << "Stop" << endl;
cout << left << "Input" << " " << "Temperature" << " " << "Temperature" << " " << "Increment" << endl;
cout << endl;

return 0;
}
put your code inside code tags and provide verbatim compiler errors.
Topic archived. No new replies allowed.