where did i go wrong here?

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
int rows,cols,i,j;
	double score[100][100],sum=0.00,ave=0.00,max=0.00,min=0.00;
	char retry;
	
		cout<<"Enter rows: ";
		cin>>rows;
		cout<<endl;
		cout<<"Enter column: ";
		cin>>cols;
		cout<<endl;
		cout<<"You will enter "<<rows*cols<<" elements in a ["<<rows<<"]x"<<"["<<cols<<"] matrix";
		cout<<endl<<endl;

// loop for score input//
			for ( i=0;i<rows;i++)
			{
				for ( j=0;j<cols;j++)
				{
					do
					{
						cout<<"["<<i<<"]["<<j<<"] :";
						cin>>score[i][j];
						sum+=score[i][j]; //computes score sum for average
					}
					while(score[i][j]<0.00 || score[i][j]>100.00);
				}
				cout<<endl;
			}
		cout<<endl<<endl;
		cout<<"You entered: "<<endl;

//loop for score output//
			for ( i=0;i<rows;i++)
			{
				for ( j=0;j<cols;j++)
				{
					
					cout.setf(ios::fixed);
					cout.setf(ios::showpoint);
					cout.precision(2);
					cout<<setw(5)<<score[i][j]<<"\t";
				}
				cout<<endl;
			}

		ave=sum/(rows*cols); // computes average
		cout<<endl;
		cout<<"The average mean score is: "<<ave;

//loop for sorting highest and lowest//	
			for ( i=0;i<rows;i++)
			{
				for ( j=0;j<cols;j++)
				{
					if (score[i][j]>max)
					{
						max=score[i][j];
					}
					if (score[i][j]<min)
					{
						min=score[i][j];
					}
				}
				cout<<endl;
			}
		cout<<"The highest score is: "<<max;
		cout<<endl;
		cout<<"The lowest score is: "<<min;
		cout<<endl;
		cout<<endl;
		cout<<endl;
	cout<<"Do you wish to try again?"<<endl<<endl;
	do
	{
		cout<<"Press Y to try again or N to go back to MENU: ";
		cin>>retry;
		toupper(retry);
	}
	while ( toupper(retry)!='Y' && toupper(retry)!='N');
	if (toupper(retry)=='Y')
	{
		scores();
	}
		else 
		{
			menu();
		}



i tried running it over and over but i cant seem to get it to display the lowest value entered, it always displays 0.00,
In this code segment (line 48- 63)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
		cout<<"The average mean score is: "<<ave;

//loop for sorting highest and lowest//	
/***********************************************************************/
min = score[0][0];                //You forgot this
/***********************************************************************/
			for ( i=0;i<rows;i++)
			{
				for ( j=0;j<cols;j++)
				{
					if (score[i][j]>max)
					{
						max=score[i][j];
					}
					if (score[i][j]<min)
					{
						min=score[i][j];
					}
				}
asymptotes14 wrote:
i tried running it over and over but i cant seem to get it to display the lowest value entered, it always displays 0.00,
Yes, you set min to 0.00 at the beginning and if there's no negative value it stays 0.00. Solution: min = score[0][0]; before line 51
thanks im getting it right now, thanks for the help again coder777
thanks im getting it right noe, thanks for the help Pravesh koirala!
Topic archived. No new replies allowed.