Computing.Net > Forums > Programming > in need of c++ help!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

in need of c++ help!

Reply to Message Icon

Name: the_jute
Date: November 14, 2006 at 15:30:28 Pacific
OS: winme
CPU/Ram: pent3
Comment:

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 stream

inFile.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 !!!



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: November 15, 2006 at 15:03:48 Pacific
Reply:

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


0

Response Number 2
Name: the_jute
Date: November 15, 2006 at 15:35:38 Pacific
Reply:

i can not get it to work for some reason


0

Response Number 3
Name: Mechanix2Go
Date: November 15, 2006 at 23:54:00 Pacific
Reply:

That narrows it right down. LOL


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 4
Name: wizard-fred
Date: November 16, 2006 at 01:28:49 Pacific
Reply:

If you have two groups to compare shouldn't you have a variables to hold the results of each group?


0

Response Number 5
Name: the_jute
Date: November 16, 2006 at 03:51:11 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: H3LL
Date: December 4, 2006 at 02:34:13 Pacific
Reply:

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 !


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: in need of c++ help!

Batch Script www.computing.net/answers/programming/batch-script/19694.html

VB6 FTP Access connection string www.computing.net/answers/programming/vb6-ftp-access-connection-string/13697.html

option buttons www.computing.net/answers/programming/option-buttons/2278.html