I have a CompSci 1 assignment, that wants me to calculate and output the windchill factor using functions, and inputs from user. I have my functions correct, I believe, but the program is running twice. When I input values in, when it runs the second time I get:
Signal: segmentation fault (core dumped)
How do I get my program to output the Windchill factor and not run again?
#include <iostream>
#include <cmath>
using namespace std;
double ctof(double tempature){
double farenheit = 9/5 * tempature + 32;
farenheit = tempature;
}
double ftoc(double tempature){
double celsius = 5/9 * (tempature - 32);
celsius = tempature;
}
double windchill(double tempature, double wind_speed, char scale){
switch(scale){
case 'C' :tempature = ctof(tempature);
break;
}
double W = 35.74+(0.6215 * tempature) - 35.75 * pow(wind_speed, 0.16) + 0.4275 * tempature * pow(wind_speed, 0.16);
switch(scale){
case 'C':
W = ftoc(W);
cout << "The windchill factor is " << W << "C degrees";
break;
case 'F':
cout << "The windchill factor is " << W << "F degrees";
break;
}
}
int main() {
double tempature;
char scale;
double wind_speed;
cout << "Input tempature including scale (Farenhit or Celcius): ";
cin >> tempature >> scale;
cout << "Input wind speed: ";
cin >> wind_speed;
windchill(tempature, wind_speed, scale);
}
output:
Input tempature including scale (Farenhit or Celcius): 107 F
Input wind speed: 20
The windchill factor is 118.378F degrees
Input tempature including scale (Farenhit or Celcius): 107 F
Input wind speed: 20
signal: segmentation fault (core dumped)