I'm stuck on how I can creat a LE object and pass it the line just input..than could i use a for loop and the .push_back to get the lines into the vector?
vector<Log_Entr y> parse(string);
This function does the following:
Open a log file specified by the parameter name (File I/O).
Read lines from the opened file.
Create a Log_Entry object passing the line just input.
Push each Log_Entry object...
User Profile
Collapse
-
Create a object passing the line just input
-
okey dokey
thanks again!!!... -
any ideas on how i can drop one of those quizzes or even just make the lowest score in the array a zero would work for me. any suggestions?Leave a comment:
-
-
ok i got it to work with :
Code:double ret_avg(float scores[], int num_scores, int tot_pts) { double sum = 0; double avg = 0; avg = 0; for (int i = 0; i < num_scores; i++) { sum = scores[i] + sum; } avg = sum / tot_pts; avg = avg * 100; return (avg); }
Leave a comment:
-
heres what i currently have in my code: the function is just printing out a 0 for the quizzes for both students.
Code:const int tot_quiz = 7; const int tot_proj = 6; const int tot_exam = 2; const int tot_labs = 14; const int tot_quiz_pts = 70; const int tot_proj_pts = 300; const int tot_exam_pts = 200; const int tot_lab_pts = 150; double ret_avg(float scores[], int num_scores,
Leave a comment:
-
ya disregard that part....i have it fixed in my program...I was just tryin stuff and I must of accidentally posted that version. something else is wrong with it.Leave a comment:
-
Okay I just tried something else but its outputting a zero when i call it and print it out...i get a 0 under --Quiz--
here it is:...i donno which is closer...my 1st func or this one.
Code:while (in_file >> Grades.student) // reads in a string into a variable { //reads in all the grades into each seperate array in_file >> Grades.quizzes[0] >>
Leave a comment:
-
whats wrong with my function?
Ok everything is good...I read in all my grades into each of the different arrays that they need to go in. Now Im trying to write a function that takes the grades and computes the average on a hundred point scale...for example:
Student 1
7 quiz scores 9 9.33 8 10 5.5 8 10 ==> the 5.5 score should be dropped, returned value: 90.55
6 project scores 20 47.5 47 45 47.5 48 ==> returned value: 94.44
... -
Okay...thanks for all the help everyone I finally figured it out!Leave a comment:
-
Code:#include <cstdlib> #include <iostream> #include <string> #include <vector> #include <fstream> using namespace std; using std::ifstream; using std::ofstream; //Structure for holding all the grades struct Grades { string student; float quizzes[7]; float projects[6];
Leave a comment:
-
okay i tried both of your suggestions and neither worked....i think it's because of the witespace that its not working. Can you please look at it again I've tried everything and i keep getting error mesages...here' s the 2 i got when i tried your suggestions:
-bash-3.00$ g++ grader.cpp
grader.cpp: In function `int main()':
grader.cpp:41: error: cannot convert `std::string' to `const char*' for argument `1' to `double atof(const...Leave a comment:
-
converting the string of a file to a float
Okay, Im having some problems with my code. Im trying to use the <cstdlib> library and im trying to convert string data at each whitespace slot. I think if you see my code you'll get what im trying to do :
Code:#include <cstdlib> #include <iostream> #include <string> #include <vector> #include <fstream> using namespace std; using std::ifstream; using std::ofstream;
-
pass values inputted using getline() to array
I need help with my program. Im trying to take input from a file and store the input into different arrays in my structure. The first pary where I get the students name worked fine but now when i try and assing the next 7 numbers into my quizzes array Im gettin problems. It's including the whitespace and therefore not accompilshing what I want to be done. Heres my file im reading in from:
Code:Smith 9 9.33 8 10 5.5 8 10 20 47.5 47 45 47.5
-
how would i do an if is alpha loop for (int i = 0, line[i] == char, i++){
student = student + line[i];}
im not sure about that one ive never done it....Leave a comment:
-
so will this work then...and then just start with some nested loops inside the while loop...
Code:#include <iostream> #include <string> #include <vector> #include <fstream> using namespace std; //Structure for holding all the grades struct Grades { string student; float quizzes[7]; float
Leave a comment:
-
storing input into arrays using a struct
Ok Im trying to use a struct to take in input from a file "grades.txt " which looks like:
Smith 9 9.33 8 10 5.5 8 10 20 47.5 47 45 47.5 48 83 87 100 98 96 100 98 92 88 96 92 86 92 94 100 96
Jones 9 8 6 6 8 7.5 8 20 35 40 42.5 40 44 62 72 100 88 86 90 92 92 88 86 88 86 94 88 86 90....etc i don't know how many students their will be.
And I need to store them in a structre like how I have in my code...Im... -
yes i know what you mean and use the "u" in the printarray(numb s2, u) instead of the n...but im not sure how to pass it from the function to main?...Leave a comment:
-
disregard that last post and for some reaosn i couldn't delete it that was when I was trying some changes of my own...heres the right code i have
its getting rid of the duplicates but im gettin some crazy extra output after i enter in some numbers. Their is one minor problem in the code and I can't find it. it compiles fine and does what i want but then additional numbers get output that weren't in the input. heres my code...Please...Leave a comment:
-
WOW that worked only one problem...its getting rid of the duplicates but im gettin some crazy extra output after i enter in some numbers. Their is one minor problem in the code and I can't find it. it compiles fine and does what i want but then additional numbers get output that weren't in the input. heres my code...Please any ideas will help... when i enter in:
3
3
4
5
6
6
7
0
output:...Leave a comment:
No activity results to display
Show More
Leave a comment: