Here is what I have in my program so far, if Celsius is under 100 it should throw integer value of 1, if the Celsius is above 100, it should throw the integer 2.
#include<iostream>
using namespace std;
int a = 1;
int b = 2;
int tempconversion() {
int f, c;
cout << "Enter temperature in Fahrenheit: ";
cin >> f;
c = (f-32)/1.8;
cout<<"Tempature in celsius is: "<<c;
return c;
try {
if( c < 0 ) {
throw a;
}
}
catch (int a) {
cout<<"Celsius below zero"<<endl;
}
try{
if( c > 100 ) {
throw b;
}
}
catch (int b){
cout<<"celsius above 100"<<endl;
}
}
int main(){
tempconversion();
}
Aucun commentaire:
Enregistrer un commentaire