Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
ok i know there is a lot of people trying to get answers for free, but i am truly stuck with my code.... here is what i have:
// This program calculates the mean, median and mode for two separate files of
// test scores. It then displays the names and scores for students from each section
// that scored a 90 or above.#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <string>using namespace std;
int main()
{
double mean; // Holds the average score by students
double median; // Holds value of median score
int mode; // Holds value of most frequent score
int scores [30][1]; // Scores 2-d array
int studentNo; // Holds position of student
int count = 0; // Initialization of count
int row; // Holds row number
int examNo; // Holds which exam was taken
int sumOfScores; // Holds the sum of all scores;total
int col; // Holds column number
string lastName [50]; // Holds students' last name
string firstName [50]; // Holds students' first name
string sectionOne = "cosc310-01.txt"; // Name of section 01's file
string sectionTwo = "cosc310-02.txt"; // Name of section 02's file
ifstream inFile; // Name of the streaminFile.open ("cosc310-01.txt"); // Reads scores out of text file
inFile >> lastName >> firstName[studentNo];
while (!inFile.eof())
{
inFile >> examNo;
for (col = 0; col < examNo; col++)
{
inFile >> scores[studentNo][col];
}
studentNo++;
inFile >> lastName >> firstName[studentNo];
}for(row=0; row < studentNo; row++)
{
sumOfScores = sumOfScores + scores[row][0];
}
mean = sumOfScores / (double)studentNo;cout << "Comparison of sections 1 and 2 of Cosc 310" << endl;
cout << " " << "Section 1" << " " << "Section 2" << endl;
cout << "Number" << endl;
cout << "Mean" << endl;
cout << "Median" << endl;
cout << "Mode" << endl;if (scores >= 90) // Identifies score is greater than or equal to 90
{
cout << "And the students who scored a 90 or above are " << lastName;
cout << firstName << scores << endl;
}
cout << "Students with scores 90 or above in Section 1" << endl;
cout << firstName << lastName << scores;cout << "Students with scores 90 or above in Section 2" << endl;
cout << firstName << lastName << scores;int FindMean [100];
int score [100];
}
i have no idea where to go from here.... :( PLEASE HELP ME !!!

What do you mean "where to go from here"?
Are you saying this code is incomplete?
Does it compile correctly?We need more info on what you need done, or what your problem is.
"Computer security." — Oxymoron

That narrows it right down. LOL
=====================================
If at first you don't succeed, you're about average.M2

what do ya mean? like:
double mean; // Holds the average score by students
double median; // Holds value of median score
int mode; // Holds value of most frequent score

you have some code of calculating meam, mode, median but in C not in C ++ ..??
If anyone can give some example or some url will be for me very userfull , thanx in advance waiting for your answer !

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |