Premature console closing

Hi I am new to CPP and am writing a program that determines how attractive a user is based on what foods they eat most and the program is cutting out before you can see the score. Please help
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;
char choice_MaleFemale;
char choice_FoodOne;
char choice_FoodTwo;
char choice_FoodThree;
char PlayAgain;
char AnyKey;
int AttractiveScore;
int FinalAttractiveScore;
int StupidScore;



int _tmain(int argc, _TCHAR* argv[])
{
cout << "Are you male or female? (M/F)" << endl;
cin >> choice_MaleFemale;
if (choice_MaleFemale == 'm'||  choice_MaleFemale == 'M')
	{
	cout << "I need to know what food you eat the most. \n If you eat pesto pasta: type 'a'. \n If you eat sushi: type 'b'. \n If you eat barbeque: type 'c'. \n If you eat take out Chinese food: type 'd'. \n If you eat raman noodles: type 'e'. \n If you eat fancy expensive food(i.e. goose liver pate): type 'f'. \n If you eat crab: type 'g'." << endl;
cin >> choice_FoodOne;
if (choice_FoodOne == 'a'|| choice_FoodOne == 'A')
	{
	AttractiveScore += 4;
	}
else if (choice_FoodOne == 'b'|| choice_FoodOne == 'B')
	{
	AttractiveScore += 6;
	}
else if (choice_FoodOne == 'c'|| choice_FoodOne == 'C')
	{
	AttractiveScore += 5;
	}
else if (choice_FoodOne == 'd'|| choice_FoodOne == 'D')
	{
	AttractiveScore += 5;
	}
else if (choice_FoodOne == 'e'|| choice_FoodOne == 'E')
	{
	AttractiveScore += 6;
	}
else if (choice_FoodOne == 'f'|| choice_FoodOne == 'F')
	{
	AttractiveScore += 0;
	}
else if (choice_FoodOne == 'g'|| choice_FoodOne == 'G')
	{
	AttractiveScore += 8;
	}
cout << "I need to know what food you eat the second most. \n If you eat pesto pasta: type 'a'. \n If you eat sushi: type 'b'. \n If you eat barbeque: type 'c'. \n If you eat take out Chinese food: type 'd'. \n If you eat raman noodles: type 'e'. \n If you eat fancy expensive food(i.e. goose liver pate): type 'f'. \n If you eat crab: type 'g'." << endl;
cin >> choice_FoodTwo;
if (choice_FoodTwo == 'a'|| choice_FoodTwo == 'A')
	{
	AttractiveScore += 4;
	}
else if (choice_FoodTwo == 'b'|| choice_FoodTwo == 'B')
	{
	AttractiveScore += 6;
	}
else if (choice_FoodTwo == 'c'|| choice_FoodTwo == 'C')
	{
	AttractiveScore += 5;
	}
else if (choice_FoodTwo == 'd'|| choice_FoodTwo == 'D')
	{
	AttractiveScore += 5;
	}
else if (choice_FoodTwo == 'e'|| choice_FoodTwo == 'E')
	{
	AttractiveScore += 6;
	}
else if (choice_FoodTwo == 'f'|| choice_FoodTwo == 'F')
	{
	AttractiveScore += 0;
	}
else if (choice_FoodTwo == 'g'|| choice_FoodTwo == 'G')
	{
	AttractiveScore += 8;
	}
cout << "I need to know what food you eat the third most. \n If you eat pesto pasta: type 'a'. \n If you eat sushi: type 'b'. \n If you eat barbeque: type 'c'. \n If you eat take out Chinese food: type 'd'. \n If you eat raman noodles: type 'e'. \n If you eat fancy expensive food(i.e. goose liver pate): type 'f'. \n If you eat crab: type 'g'." << endl;
cin >> choice_FoodThree;
if (choice_FoodThree == 'a'|| choice_FoodThree == 'A')
	{
	AttractiveScore += 4;
	}
else if (choice_FoodThree == 'b'|| choice_FoodThree == 'B')
	{
	AttractiveScore += 6;
	}
else if (choice_FoodThree == 'c'|| choice_FoodThree == 'C')
	{
	AttractiveScore += 5;
	}
else if (choice_FoodThree == 'd'|| choice_FoodThree == 'D')
	{
	AttractiveScore += 5;
	}
else if (choice_FoodThree == 'e'|| choice_FoodThree == 'E')
	{
	AttractiveScore += 6;
	}
else if (choice_FoodThree == 'f'|| choice_FoodThree == 'F')
	{
	AttractiveScore += 0;
	}
else if (choice_FoodThree == 'g'|| choice_FoodThree == 'G')
	{
	AttractiveScore += 8;
	}
AttractiveScore -= StupidScore = FinalAttractiveScore;
if (FinalAttractiveScore <= 10&& FinalAttractiveScore >= 0)
	{
	cout << "You scored " << FinalAttractiveScore << " on the test, that means you are quite unattractive. Sucks to be you." << endl;
	}
else if (FinalAttractiveScore >= 10&& FinalAttractiveScore <= 15)
	{
	cout << "You scored " << FinalAttractiveScore << " on the test, that means you are unattractive." << endl;
	}
else if (FinalAttractiveScore >= 16&& FinalAttractiveScore <= 19)
	{
	cout << "You scored " << FinalAttractiveScore << " on the test, that means you are not attractive or unattractive, sort of in the middle." << endl;
	}
else if (FinalAttractiveScore >= 20&& FinalAttractiveScore <= 23)
	{
	cout << "You scored " << FinalAttractiveScore << " on the test, that means you are attractive." << endl;
	}
else if (FinalAttractiveScore >= 24&& FinalAttractiveScore <= 30)
	{
	cout << "You scored " << FinalAttractiveScore << " on the test, that means you are extremely attractive." << endl;
	}
else if (FinalAttractiveScore >= 30)
	{
	cout << "Obviously you have found some way to cheat the system because the score is out of 30, and you scored " << FinalAttractiveScore << " on the test. Go away. I don’t like you anymore. You broke my program." << endl;
	}
	}
else if (choice_MaleFemale == 'f'|| choice_MaleFemale == 'F')
	{
//the same function goes here but the scores are a little different, unfortunately my program was too long and the website wouldnt let me post it all
	}
}
It's because you haven't declare the gringo variable to determine exit status.

Jk

Please read the board entry called closing the console program. It will tell you how to keep the console open long enough so you can see output.
pogrady, thank you i read the entry and it had several good replies and it worked the console is now staying open as long as i want it to.
hey, just a hint, rather than doing something like
 
if(choice == 'A' || choice == 'a') ...


You could do something like
 
if(tolower(choice) == 'a') ...


This will convert upper case letters to lowercase and leave lowercase alone, it will cleanup your code a bit.
Topic archived. No new replies allowed.