Can't figure out why program keeps exiting.

Having a little trouble with this.

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
/*
	Lab3A
*/

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

using namespace std;

void main()
{
	// declaration and initialization
	string diverName, city;
    double score, total_score, final_score = 0;
    double difficulty;
    double highest, lowest, overall;
    char process_diver;
    int judge_ctr, num_divers = 0;
	// heading         
    cout << "Report to the media\n";
    cout << "Event: Diving competition\n\n";
    // formatting 
	cout << fixed << showpoint << setprecision(2);

    do
	{
		cout << "Enter the diver's name: ";
        getline(cin, diverName);

        cout << "Enter the diver's city: ";
        getline(cin, city);

        highest = -1;
        lowest = 11;
        total_score = 0;
        judge_ctr = 1;
        do
        {		
			cout << "Enter the score given by judge #"
                        << judge_ctr << ": ";
            cin >> score;

			if (score <= 0 || score >= 11)
			{
			cout << "Values must be between 0 and 10.";
			cout << "Enter the score given by judge # " << judge_ctr << ": ";
			cin >> score; }
		
			total_score += score;
            judge_ctr++;
		
	} 
		while (judge_ctr <= 5);
		
		
			cout << "Enter between 1.0 and 1.67 inclusive." << endl;
			cout << "What was the degree of difficulty? ";
			cin >> difficulty;
        
		if (difficulty <= 0.9 || difficulty >= 1.68)
		{
			cout << "Invalid range. Choose between 1.0 and 1.67";
		    cout << "What was the degree of difficulty? ";        
		    cin >> difficulty;
		}
	
		overall = (total_score - lowest - highest) / 3 * difficulty; 
		
		
		cout << "Diver: " << diverName << ", City: " << city<< endl;
        final_score = final_score + overall;
        num_divers = num_divers + 1;
		cout << "Overall  score was " << final_score <<"."<< endl;
		cout << "\nDo you want to process another diver (Y/N)? ";
        cin >> process_diver;
        process_diver = toupper(process_diver);      
        cin.ignore(50, '\n');
               
    } 
	while (process_diver == 'Y' || process_diver =='y');


    cout << "EVENT SUMMARY\n";
    cout << "Number of divers participating: " << num_divers << endl;
    cout << "Average score of all divers: "<< final_score / num_divers << endl;
}




Report heading

Loop as long as there are divers to process
Input diver's name and city
Initialize highest score, lowest score and total score

Using a do-while loop input the 5 judge's scores
Validate the score to ensure it is between 0 and 10
Add score to total
Determine highest and lowest scores

Input and validate the degree of difficulty
Calculate the overall diver's score

Display the diver's information and overall score
Add diver's overall score to the final score
Add 1 to the number of divers

Prompt the user to process another diver
End-Loop

Calculate the average score for all divers
Display the number of divers and the average score for all divers
:


The event summary never shows up, or it automatically exits before I can see it. Everything else seems to work. I know it's something simple, but my eyes just can't see it.
add a cin.get at the end.
your codes compiled and work fine in my cfree-5 with a little change, main mush have an int return. look at this and compile it.
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
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
	// declaration and initialization
	string diverName, city;
    double score, total_score, final_score = 0;
    double difficulty;
    double highest, lowest, overall;
    char process_diver;
    int judge_ctr, num_divers = 0;
	// heading         
    cout << "Report to the media\n";
    cout << "Event: Diving competition\n\n";
    // formatting 
	cout << fixed << showpoint << setprecision(2);

    do
	{
		cout << "Enter the diver's name: ";
        getline(cin, diverName);

        cout << "Enter the diver's city: ";
        getline(cin, city);

        highest = -1;
        lowest = 11;
        total_score = 0;
        judge_ctr = 1;
        do
        {		
			cout << "Enter the score given by judge #"
                        << judge_ctr << ": ";
            cin >> score;

			if (score <= 0 || score >= 11)
			{
			cout << "Values must be between 0 and 10.";
			cout << "Enter the score given by judge # " << judge_ctr << ": ";
			cin >> score; }
		
			total_score += score;
            judge_ctr++;
		
	} 
		while (judge_ctr <= 5);
		
		
			cout << "Enter between 1.0 and 1.67 inclusive." << endl;
			cout << "What was the degree of difficulty? ";
			cin >> difficulty;
        
		if (difficulty <= 0.9 || difficulty >= 1.68)
		{
			cout << "Invalid range. Choose between 1.0 and 1.67";
		    cout << "What was the degree of difficulty? ";        
		    cin >> difficulty;
		}
	
		overall = (total_score - lowest - highest) / 3 * difficulty; 
		
		
		cout << "Diver: " << diverName << ", City: " << city<< endl;
        final_score = final_score + overall;
        num_divers = num_divers + 1;
		cout << "Overall  score was " << final_score <<"."<< endl;
		cout << "\nDo you want to process another diver (Y/N)? ";
        cin >> process_diver;
        process_diver = toupper(process_diver);      
        cin.ignore(50, '\n');
               
    } 
	while (process_diver == 'Y' || process_diver =='y');


    cout << "EVENT SUMMARY\n";
    cout << "Number of divers participating: " << num_divers << endl;
    cout << "Average score of all divers: "<< final_score / num_divers << endl;
    
    system("pause");
    return EXIT_SUCCESS;
}
Topic archived. No new replies allowed.