0

Can anybody help me figure out how to fix this so it would come out the highest & lowest score???

#include <iostream>
#include <iomanip>
using namespace std;

int main()

{
    double *score;
    double total = 0;
    double average;
    double max = 0;
    double min = 0;
    int testscore;
    int count = 1;


    cout << "Enter how many scores do you have: ";
    cin >> testscore;
    score = new double[testscore]; // Allocate memory



    // Get the Test Scores
    cout << "\n";

    for (count = 1; count <= testscore; count++)
    {
    cout << "Enter score #"<<count<<": ";
    cin >> score[count];
    cout <<"\n";
    }

    // Calculate the total Scores
    for (count = 1; count <= testscore; count++)
    {
    total += score[count];
    }

    // Calculate the average Test Scores
    average = total / testscore;
    if (score[count]> max)
    {
    max = score[count];
    }
    if (count == 0)
    {
    min = score[count];
    }
    if (score[count] < min)
    {
    min = score[count];
    }

    // Display the results
    cout << fixed << setprecision(2);


    cout <<"----------------------------\n";
    cout <<"The highest score is: "<<max<<"\n\n";
    cout <<"The lowest score is: "<<min<<"\n\n";
    cout <<"The average score is: "<<average<<"\n\n";

    system ("pause");
    return 0;
}

Edited by mike_2000_17: Fixed formatting

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by caromok
0

JUST TRY OUT THIS CODE...
I DONT HAVE A COMPLIER TO EXEC MY CODE...
PLS DO TRY IT

Regds,
Caro

#include<iostream.h>
void main()
{
//Declaration
int Tot_Entry;
int Arr[Tot_Entry];
int Avg_Score;
int Tot_Score;

// Get the Total Entry
cout<<"Enter the number of entries";
cin>>Tot_Entry;
// Get the Test Scores
cout<<"Enter each score one by one";
for(int i=0; i<=Tot_Entry;i++)
cin>>Arr;
// Calculate the total Scores
for(int i=0; i<=Tot_Entry;i++)
Tot_Score=Tot_Score+Arr;
// Calculate the average Test Scores
cout<<"Average Test Score";
Avg_Score=Tot_Score/Tot_Entry;
cout<<Avg_Score;
//Highest and Lowest Scores-(AFTER SORTING-->Topmost (Highest) Lastone--Lowest)
for(int i=0; i<=Tot_Entry;i++)
{
for(int j=i+1; j<=Tot_Entry;j++)
{
if (Arr<Arr[j])
{
int Temp;
//Swapping
Temp=Arr;
Arr=Arr[j];
Arr[j]=Temp;
}
}
}
// Display the results
cout<<"Number of Score Entries"<<Tot_Entry;
cout<<"Each Score Entry";
for(int i=0; i<=Tot_Entry;i++)
cout<<Arr;
cout<<"Total Scores"<<Tot_Score;
cout<<"Average Test Score"<<Avg_Score;
cout<<"Highest Score"<<Arr[0];
cout<<"Lowest Score"<<Arr[Tot_Entry];
}

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.