User Profile

Collapse

Profile Sidebar

Collapse
joestevens232
joestevens232
Last Activity: Nov 18 '08, 11:40 PM
Joined: Oct 30 '06
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • joestevens232
    started a topic Create a object passing the line just input
    in C

    Create a object passing the line just input

    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...
    See more | Go to post

  • joestevens232
    replied to whats wrong with my function?
    in C
    okey dokey

    thanks again!!!...
    See more | Go to post

    Leave a comment:


  • joestevens232
    replied to whats wrong with my function?
    in C
    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?
    See more | Go to post

    Leave a comment:


  • joestevens232
    replied to whats wrong with my function?
    in C
    got it...thank you!!!
    See more | Go to post

    Leave a comment:


  • joestevens232
    replied to whats wrong with my function?
    in C
    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);
    }
    but my output is 85.4714 for the...
    See more | Go to post

    Leave a comment:


  • joestevens232
    replied to whats wrong with my function?
    in C
    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,
    ...
    See more | Go to post

    Leave a comment:


  • joestevens232
    replied to whats wrong with my function?
    in C
    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.
    See more | Go to post

    Leave a comment:


  • joestevens232
    replied to whats wrong with my function?
    in C
    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] >>
    ...
    See more | Go to post

    Leave a comment:


  • joestevens232
    started a topic whats wrong with my function?
    in C

    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
    ...
    See more | Go to post

  • Okay...thanks for all the help everyone I finally figured it out!
    See more | Go to post

    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];
    ...
    See more | Go to post

    Leave a comment:


  • joestevens232
    replied to converting the string of a file to a float
    in C
    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...
    See more | Go to post

    Leave a comment:


  • joestevens232
    started a topic converting the string of a file to a float
    in C

    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;
    ...
    See more | Go to post

  • joestevens232
    started a topic pass values inputted using getline() to array
    in C

    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
    ...
    See more | Go to post

  • joestevens232
    replied to storing input into arrays using a struct
    in C
    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....
    See more | Go to post

    Leave a comment:


  • joestevens232
    replied to storing input into arrays using a struct
    in C
    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
    ...
    See more | Go to post

    Leave a comment:


  • joestevens232
    started a topic storing input into arrays using a struct
    in C

    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...
    See more | Go to post

  • joestevens232
    replied to removing duplicates in an array
    in C
    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?...
    See more | Go to post

    Leave a comment:


  • joestevens232
    replied to removing duplicates in an array
    in C
    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...
    See more | Go to post

    Leave a comment:


  • joestevens232
    replied to removing duplicates in an array
    in C
    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:...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...