Thread: grade distribution CODE program

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    4

    Unhappy grade distribution CODE program

    To help you guys better help me out ill show you a program that is somewhat similar of what i need that was in my C++ book... for those who dont know, i need to make a bar graph of grades from 3 different classes, the grades must be read from a text file and i need to use at least 1 function... here goes:

    this program generates bar graphs of monthly sales by dept for 2 stores

    Code:
    #include <iostream.h>
    #include<iomanip.h>
    #include<fstream.h>
    
    void GetData(ifstream&, int&, float&);
    void PrintData(int, int, float);
    void Printheading();
    
    int main()
    {
    int deptID1;     //dept id number for store1
    int deptID2;    //dept id for store 2
    float sales1;     //dept sales for store 1
    float sales2;      //dept sales for store2
    ifstream store1;  //accounting file for store1
    ifstream store2;     //accounting file for store2
    
    store1.open("store1.txt");
    store2.open("store2.txt");
    if(!store1 || !store2)
    {
    cout<<"Cant open files"<<endl;
    return 1;
    }
    
    Printheading();
    GetData(store1, deptID1, sales1);    //process store1
    GetData(store2, deptID2, sales2);    //process store2
    while(store1 && store2)
    {
    cout<<endl;
    PrintData(deptID1, 1, sales1);
    PrintData(deptID2, 2, sales2);
    GetData(store1, deptID1, sales1);
    GetData(store2, deptID2, sales2);
    }
    return 0;
    }
    
    void Printheading();
    {
    cout
    <<"Bar Graph Comparing Depts of Store #1 and #2"
    <<endl <<endl
    <<"store sales in 1000s of dollars<< endl
    <<" #         0        5            10       15      20"
    <<endl
    <<"|-----|-----|-----|-----|-----|-----|"
    <<endl;
    }
    
    void GetData(ifstream& dataFile,       //input file
                          int& deptID,        //dept number
                            float& deptSales) // dept monthly sales      
    {
    int numDays
    int day;
    float sale;
    dataFile>> deptID;
    if(!dataFile)
    else;
    
    dataFile>> numDays;
    deptSales = 0.0;
    day=1;       //initialize loop control varible
    while(day<=numDays)
    {
    dataFile>> sale;
    deptSales= deptSales + sale;
    day++;        //update loop control varible
    }
    }
    
    void PrintDtat(int deptID,
                            int storeNum,
                            float deptSales)
    {
    cout<<setw(12)<<"dept"<<deptID<<endl;
    cout<<setw(3)<<storeNum<<"      ";
    while(deptSales> 250.0)
    {
    cout<<"*";
    deptSales=deptSales-500.0;
    }
    cout<<endl;
    }

    hopefully u can use this to incorporate my grade program, ive tried for days to try to figure this out, my copy is at school, i had forgotten to print it out so someone could tell me where i went wrong but i used the basis of this program for my own, im not good at being given a book and having to figure things out for myself but my teacher thinks thats the best way to learn it... thanks everyone!
    Last edited by MyTeachersANazi; 03-27-2003 at 03:47 PM.

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    Books are good, but there are books out there that do not explain topics very well; so multiple books should be looked at.

    This code doesn't really help us help you because it is not the actual program. When you have the code with you, post a copy of that, and then we can help you with the actual program. We could write it for you, except for two things; one, you won't learn anything; two, we won't do it (at least most wouldn't). we are willing to help, not do your homework.

    So post your code of the program, explain what exactly is giving you trouble, and we'll be more than willing to help explain.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    4
    im only 16 years old, i took this class thinking that i was going to one day be a programmer but the teacher unfortunately ruined any chance of that ever happening, im totally lost in the class and im close to failing, at the beginning of the year we had close to 30 people now we have 6 and the only reason im still in the class b/c i refuse to withdrawl from the class and fail and drop my GPA (even though its going to anyways w/a D) im not a bad student as of now my GPA is a 3.6... yeah you can say you wont show me the program b/c i wont learn and your right but frankly i dont care about learning anything more in this class... im counting down the days until im out, and if you dont want to give me any hope of passing then fine i guess thats something im goin to have to deal with. but i mean its not like ive asked everyone for help without even trying or even keep asking about every program. i needed help w/a starting point and some guidance but thanks for further deterring me from wanting to be a programmer also.

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    woah, woah, woah. I am in no way deterring you to not become a programmer. You have to try, you cannot learn if you do not try. So you have a bad teacher, then you know what, you need to go out and learn yourself. And if you take another class, hopefully you will have a better teacher. I have had bad teachers as well, but that has not deterred me from learning a subject.

    As you say, you wanted to be a programmer. If it is really in your heart, you will not just go by the class, you will go out and learn things on your own and actually try to "learn". With your current attitude about not caring, then you are not set to be a programmer.

    Programming is not easy, and I know that. But there are struggles everywhere. Your age has nothing to do with it, except that you have numerous experiences left. I'm still in high school, I'm a senior. I know how it can be with bad teachers. But I also expect that there may be professors in college that may not explain everything to where I can understand it. Also, on the jobsite, bosses and coworkers are not always there to write programs for you.

    I am more than willing to help you to the best of my ability; however, how can I help you with the above code. You need to provide the code that you are currently working on, or create an example of the concepts/code you are having trouble with. If you give code that runs and compiles and don't have any questions on it, what are we supposed to do. Great, I copied and pasted code, compiled it, and ran it. What does that do for me?

    If you have trouble, you need to ask questions on what is exactly troubling you. A lot of us do not need an example to know how to write the program you need; for example, I could write it tonight.

    But as you said, you want to become a programmer. And if it is truly in your heart, you will try and ask questions. You won't get too far in life if you give up because of one bad experience that happens to be with a teacher that doesn't help students understand.

    Has your experience truly been that bad that it has ruined your life? You can overcome this; unless your teacher is vindictive and fails you even if you do the work and should be getting an A. I have experienced this. I have had teachers give me Cs or lower; and when I confront them about it, it somehow gets corrected to what my grade should be, especially when administration becomes involved.

    So, you're counting the days till you get out. Great, we've all been there. But as I have repeatedly said, if you really want to be a programmer, help yourself by letting us help you with what you have trouble with in your program.


    So, you say you have tried it. When you are able to print the code you have, post it. Then ask questions where you are having trouble, what you do not understand, and we will be more than happy to help you.

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    75
    geez sounds like you are about to cry

    dude who cares how bad your teacher is...
    Many programmers self teach themselves, which cannot be any easier then having a bad teacher. Go online look around for tutorials, ask questions not for complete code written out for you.

    And as for the 16 year old shat...at the age of 12 you have the mental/brain capacity of an adult. You are 4 years past that age, you should be damned smart by now ;P
    MSVC++~

  6. #6
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    I guarantee you that almost everyone on this board self-taught themselves the majority of what they know. Like everyone else here says, if you want to program then get a few books or look at a few online tutorials and have at it. The people here can recommend MANY books and places to check out if you are interested.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need the code of few programs in c++.plzzzzz help...plzzz
    By NAVINKR20 in forum C++ Programming
    Replies: 1
    Last Post: 05-08-2009, 09:13 AM
  2. How Can I compile 3 source code in 1 program ?
    By lord_cedrich in forum C Programming
    Replies: 8
    Last Post: 12-10-2006, 05:10 AM
  3. Please test my program: Code Black
    By PhoenixC++ in forum Windows Programming
    Replies: 15
    Last Post: 04-29-2004, 07:18 PM
  4. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM