Click here to Skip to main content
15,921,113 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: Can anyone help me? Pin
led mike30-Oct-06 4:53
led mike30-Oct-06 4:53 
AnswerRe: Can anyone help me? Pin
Christian Graus30-Oct-06 16:25
protectorChristian Graus30-Oct-06 16:25 
QuestionPriority to system timers Pin
RSangeetha29-Oct-06 21:59
RSangeetha29-Oct-06 21:59 
AnswerRe: Priority to system timers Pin
Jonathan [Darka]30-Oct-06 3:46
professionalJonathan [Darka]30-Oct-06 3:46 
Questiongames Pin
ammoh29-Oct-06 20:56
ammoh29-Oct-06 20:56 
AnswerRe: games Pin
toxcct30-Oct-06 5:29
toxcct30-Oct-06 5:29 
AnswerRe: games Pin
Vega0230-Oct-06 9:55
Vega0230-Oct-06 9:55 
QuestionInputing data from .txt to array. Pin
Ramper29-Oct-06 15:58
Ramper29-Oct-06 15:58 
I have a program that is able to take the numbers out of the .txt if it is just a list of numbers. Problem is, I have a file with Names before the grades. I believe i need to set up another array inside the first one to fill with names. The .txt file will look like:

Name
grade
grade
grade
grade
grade
grade
grade
grade
grade
grade
Name
...

Have 15 Names with 10 grades under each. I guess what i'm trying to do is take the strings out of the file. Is there a way to take the strings(there is a string every 11 lines)

Here is what i have now:

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

const int TESTS = 10;
const int STUDENTS = 15;

void displayGrades( int [][TESTS] );
void getGrades( int [][TESTS]);

int main()
{
int data[STUDENTS][TESTS] = {0};

getGrades( data );

cout <<fixed <<setprecision(1);

displaygrades(="" data);

#ifdef="" win32
system("pause");
#endif
return="" 0;
}

void="" getgrades(int="" data[]="" [tests])
{
ifstream="" inputfile;
inputfile.open("gradespring07.txt");
if="" (!inputfile)
{

cout="" <<="" "error="" opening="" file!"="" endl;
exit(="" 1="" );
}





for="" (int="" student="0;" student<="" students="" ;="" student++)
{
for="" test="0;" test<tests;test++)
{


inputfile="">> data[student][test];





}

}
}
void displayGrades( int data[][TESTS] )
{

double testTotal = 0.0;
double classTotal = 0.0;
double squared = 0.0;
double var = 0.0;
double sdev = 0.0;
int mxm = data[0][0];
int min = data[0][0];

cout << "\nGrade summary" << endl;
cout << "--------------" << endl;
cout << left << setw(7) << "Student"
<< right << setw(5) << right << "Ex1"
<< setw(7) << "Ex2"
<<setw(6) <<="" "ex3"
<<setw(6)="" "qz1"
<<setw(5)="" "qz2"
<<setw(6)="" "qz3"
<<setw(6)="" "qz4"
<<setw(6)="" "qz5"
<<setw(6)="" "pr1"
<<setw(6)="" "pr2"
<<setw(8)="" <<"averg"="" <<endl;

for="" (="" int="" student="0;" <="" students;="" ++)
{
cout="" left="" <<setw(7)="" +="" 1;

for="" test="0;" tests;="" test++)
{
int="" grade="data[student][test];
cout" right="" <<setw(5)="" <<"="" ";


classtotal="" average="(((data[student][0]+data[student][1]+data[student][2])/3)*0.4)+(((data[student][8]+data[student][9])/2)*0.3)+(((data[student][3]+data[student][4]+data[student][5]+data[student][6]+data[student][7])/5)*0.3);
cout" setw(7)="" endl;


}

cout="" "\n"="" "test="" avg";

for="" (int="" test++)
{
for="" student++)
{
testtotal="" setw(6)="" testtotal="" students;

testtotal="0.0;
}

cout" endl;

cout="" "stan="" dev";

for="" student++)
{
squared="" 2.0);
var="(squared" -="" ((testtotal="" *="" testtotal)="" 15)="" )="" 15;
sdev="sqrt(var);
}

cout" sdev;

sdev="0.0;

}

cout" "max";

for="" student++)
{

if="" (data[student][test]=""> mxm)
{

mxm = data[student][test];
}
}

cout << right <
AnswerRe: Inputing data from .txt to array. Pin
Jun Du30-Oct-06 14:15
Jun Du30-Oct-06 14:15 
QuestionCan someone help me with sound control? Pin
crystal0049029-Oct-06 5:26
crystal0049029-Oct-06 5:26 
AnswerRe: Can someone help me with sound control? Pin
Mark Salsbery29-Oct-06 17:46
Mark Salsbery29-Oct-06 17:46 
Questioncan u help me Pin
scorpioninstyle28-Oct-06 9:08
scorpioninstyle28-Oct-06 9:08 
AnswerRe: can u help me Pin
Christian Graus28-Oct-06 11:27
protectorChristian Graus28-Oct-06 11:27 
QuestionLinux Active Process List Pin
feritunal27-Oct-06 22:52
feritunal27-Oct-06 22:52 
AnswerRe: Linux Active Process List Pin
George L. Jackson28-Oct-06 6:20
George L. Jackson28-Oct-06 6:20 
QuestionBYTE to unsigned char Pin
samkook27-Oct-06 12:54
samkook27-Oct-06 12:54 
AnswerRe: BYTE to unsigned char Pin
Christian Graus27-Oct-06 15:54
protectorChristian Graus27-Oct-06 15:54 
GeneralRe: BYTE to unsigned char Pin
samkook27-Oct-06 19:12
samkook27-Oct-06 19:12 
GeneralRe: BYTE to unsigned char Pin
Christian Graus28-Oct-06 2:19
protectorChristian Graus28-Oct-06 2:19 
GeneralRe: BYTE to unsigned char Pin
samkook28-Oct-06 9:08
samkook28-Oct-06 9:08 
GeneralRe: BYTE to unsigned char Pin
Christian Graus28-Oct-06 11:26
protectorChristian Graus28-Oct-06 11:26 
GeneralRe: BYTE to unsigned char Pin
Mark Salsbery29-Oct-06 17:23
Mark Salsbery29-Oct-06 17:23 
QuestionUser Painted TextBox Pin
Tojiro26-Oct-06 8:39
Tojiro26-Oct-06 8:39 
Questionwriting test results in XML file using CPPUnit Pin
jayart26-Oct-06 5:21
jayart26-Oct-06 5:21 
QuestionUnmanaged pointer in managed collection Pin
Jose M Castellanos26-Oct-06 1:15
Jose M Castellanos26-Oct-06 1:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.