Trouble printing right output

Hi, I'm trying to make a simple temperature converter with a menu that lets
users pick which conversion to perform. But, it won't seem to print the right
conversion. It just prints the same temperature that I inputted.

for example:

Temperature Calculator

******************************
******************************
||                          ||
||1. Celsius to Farenheit   ||
||                          ||
||2. Farenheit to Celsius   ||
||                          ||
||3. Kelvin to Celsius      ||
||                          ||
||4. Kelvin to Farenheit    ||
||                          ||
||5. Celsius to Kelvin      ||
||                          ||
||6. Farenheit to Kelvin    ||
||                          ||
******************************
******************************
Enter a menu option:

1
Enter the temperature you wish to convert:

35
35
Press any key to continue . . .






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <iostream>

using namespace std;

//prints the menu
void userMenu(){

	cout << "Temperature Calculator" << endl << endl;

	cout << "******************************" << endl
		 << "******************************" << endl
		 << "||                          ||" << endl
		 << "||1. Celsius to Farenheit   ||" << endl
		 << "||                          ||" << endl
		 << "||2. Farenheit to Celsius   ||" << endl
		 << "||                          ||" << endl
		 << "||3. Kelvin to Celsius      ||" << endl
		 << "||                          ||" << endl
		 << "||4. Kelvin to Farenheit    ||" << endl
		 << "||                          ||" << endl
		 << "||5. Celsius to Kelvin      ||" << endl
		 << "||                          ||" << endl
		 << "||6. Farenheit to Kelvin    ||" << endl
		 << "||                          ||" << endl
		 << "******************************" << endl
		 << "******************************" << endl;
}

//@param userChoice- picks which conversion to perform
//@param userTemp- takes user inputted temperature and returns the newly converted temp

int menuOpt(int userChoice, int userTemp){

	int newTemp;

	switch(userChoice){
		case 1:
			newTemp = ( (userTemp * (9/5)) + 32 );
			return newTemp;
			break;
		case 2:
			newTemp = ( (userTemp - 32) * (5/9) );
			return newTemp;
			break;
		case 3:
			newTemp =userTemp - 273;
			return newTemp;
			break;
		case 4:
			newTemp = ((9/5) * (userTemp - 273)) + 32;
			return newTemp;
			break;
		case 5:
			newTemp = userTemp +273;
			return newTemp;
			break;
		case 6:
			newTemp = ((5/9) * (userTemp - 32)) + 273;
			return newTemp;
			break;
		default:
			cout << endl << "Invalid input. Program terminated." << endl;
			break;
	}


}

//based on the input, will return a string containing the degree name(i.e celsius, farenheit, kelvin)
string degreeOut(int input){
	
	string degName;
	
	switch(input){
	case 1:
	case 4:
		degName = "Farenheit";
		return degName;
		break;
	case 2:
	case 3:
		degName = "Celsius";
		return degName;
		break;
	case 5:
	case 6:
		degName = "Kelvin";
		return degName;
		break;
	default:
		exit(1);
	}

}

int main() {

	int userInput;
	int userTemp;
	string degreeUnit;

	userMenu(); 

	cout << "Enter a menu option:" << endl << endl;
	cin >> userInput;

	cout << "Enter the temperature you wish to convert: " << endl << endl;
	cin >> userTemp;

	degreeUnit = degreeOut(userInput);

	menuOpt(userInput, userTemp);

	cout << userTemp << endl;

return 0;

}



Could someone please tell me what I'm doing wrong?
You just made 1 mistake at the end. The function "menuOpt" returns converted input but you just print out the original input.

menuOpt(userInput, userTemp);

cout << userTemp << endl;

should be

cout << menuOpt(userInput, userTemp) << endl;


Ohhh, thanks. It worked!!!
Topic archived. No new replies allowed.