Thread: Just stuck indeed

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    5

    Just stuck indeed

    Hello,I just started to study C++ by myself and having troubles..lot of troubles i especialy with (6),(7)...anyone knows CPP well enaugh?thank you people.....
    I'm trying writing a program including information about a student in college:
    (1)id number of the student (2)name of the student-static string of 20 (3)pointers array of 10 courses(each student studies maximum 10 courses) (4)array of final grades in the studied courses (5)every student can have data about less than 10 courses so the ammount of the actualy studied courses must(!!) be memorized/stored. (6)output function-student can be registered to course only if he stands by all the requirement for every course (7)input..
    The MAIN function must present a menu for students wishing to make registration for courses and managing theirs grades,maximum students in college are 5...
    Code:
          #include <iostream>
     
          
          Class student {
    
          long student_number;
      
          char student_name[20];
       
          Course *course_arr[10] ;//pointers array??
       
          int grades_list[10];
       
          int Actual_courses_studied();
       
          require() { // supposed to be the (6)..dont know how to start even define it..
      
          Input_func() ;
      
          Output_func() { }
      
          }
      
           
      
          int Student :: Input_func() {
      
          if require()<>NULL
      
          cout<<"type student name and id"
      
          cin>> student_number>>student_name }
      
           
      
          int Student::Actual_courses_studied() {
      
          for (i=0,i<10,i++)
      
          if *course_arr[i]<>NULL
      
          z++
     
          return z }
      
           
      
          void main() {
      
          student A;
      
          A.Input_func();
      
           
      
           
      
          }
    //have no idea,broke my head how i make the main requirment
    Last edited by Salem; 11-19-2007 at 04:24 PM. Reason: Remove double code tags

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    If you are studying by yourself where did you get those somewhat strage requirements from? I mean it has detailed description of the implementation of the students but a very vague description of what this program must achieve.

    (1)id number of the student
    (2)name of the student-static string of 20
    Since you are trying to achieve something non-trivial, may-be use a higher-level std::string.

    (3)pointers array of 10 courses(each student studies maximum 10 courses)
    May-be just an array of courses (or a std::vector).

    (4)array of final grades in the studied courses
    This might be grouped together in a class/struct with the course data (name, id?).

    (5)every student can have data about less than 10 courses so the ammount of the actualy studied courses must(!!) be memorized/stored.
    OK

    (6)output function-student can be registered to course only if he stands by all the requirement for every course
    So, you'll need a list of another type course objects that also store the requirements (for that you could use the same object as in the Student class, that has the course name and minimum required marks. You'll need to get this data somewhere (loaded from file?)

    (7)input..
    The MAIN function must present a menu for students wishing to make registration for courses and managing theirs grades,maximum students in college are 5...
    So given the list of completed courses in a student object, you should check for each available course if the student has met the requirements and present these to be selected in a menu.

    To grade the students you have to assign them fake marks? (Or may-be include mini-games )

    It is a good and challenging exercise but could you try to formulate the requirements better and your plan how to achieve those?

    (All in all, I suspect you might need more classes than just the student.)
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    http://cboard.cprogramming.com/showthread.php?t=88495
    Slow down and write smaller steps.

    You're sort of on the right track, but you need to press "compile" a lot more frequently to check it actually compiles, and also run it from time to time as well.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    ...especialy with (6),(7).
    Since there are no details for (6), I assume this is a type-bool for each course.... Either the requirements are met or not. Since there is no critera given, I would assume that you just need a way to enter (and store) "yes" or "no". I would write that part of the program last... Up to that point, you can display all of the data, just to make sure everything's working. When when all of the other program features are working, you can put in the code to strip-out the non-qualified cources.

    (7) is probably just a sequence of cout questions, and cin answers. (i.e. "Enter Student ID", "Enter Student Name" ) Of course you'll need a loop to enter more than one student, and a nested loop for each course. (But, don't make a loop, until your program works with one student and one course.) I would start by writing (and debugging) this input code first! I would assume that to "manage" the data, means that you need menu options to enter a new student, and to edit the records of existing students.

    Start with a simple version of the program... Just get the ID, put it into a class, and then display it. Add one feature at a time... Next, you can add another student ID, or the name of the first student. But, don't try to do everything at once.... just add (and debug) one or two lines at a time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 10-23-2006, 07:22 PM
  2. string array stuck:(
    By mass in forum C Programming
    Replies: 18
    Last Post: 05-22-2006, 04:44 PM
  3. Program stuck in infinite loop-->PLEASE HELP
    By Jedijacob in forum C Programming
    Replies: 5
    Last Post: 03-26-2005, 12:40 PM
  4. Stuck on random generating
    By Vegtro in forum C++ Programming
    Replies: 3
    Last Post: 10-01-2003, 07:37 PM
  5. stuck ky
    By JaWiB in forum Tech Board
    Replies: 2
    Last Post: 06-15-2003, 08:28 PM