soda machine program

This is a discussion on soda machine program within the C++ Programming forums, part of the General Programming Boards category; Hello everyone! I have been learning about classes and this is my first program using classes. I would like to ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    76

    soda machine program

    Hello everyone!

    I have been learning about classes and this is my first program using classes.
    I would like to know how bad I did.

    I am interested in opinions.


    Also I have a constant global there and I am not sure this is a good way to declare this variable.
    Attached Files Attached Files

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,812
    The only thing I saw was in sodaMachine::sodaSelection(). Why do you use that array when a single int would do.
    Code:
    int code;
    
    cin>>code;
    
    switch(code)
    {
    //do your choices here
    }
    //finish up
    Oh and the same function your thank you message should be outside of the loop not in it.
    Last edited by prog-bman; 05-01-2006 at 05:22 AM.
    Woop?

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    27
    Hey man this part of the code is wrong ...
    i and j have out of boundary values after the for loop...
    you ask the user to give softDrinkCode[3][2] which is a logic mistake..

    Code:
      cout << "please enter code:  "; cin >> softDrinkCode[i][j];
               switch(softDrinkCode[i][j])
    so you should get i and j separately from the user or you could do what prog-bman said ...

    and next time try to find your mistakes in the program by testing it thoroughly yourself

  4. #4
    Registered User
    Join Date
    Feb 2005
    Posts
    76
    definately some good advice friends. I used a two dimensional array so I could use codes like a1, or b2 etc.. but I did not get it figured out yet.

    I also noticed that my thank you not was outside the loop. oops! that was a mistake I should have found.

    Also, I am not quite used to two dimensional arrays and such but with input from others and practice I will get better.

    Thanks for the tip on separating i and j.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. c++ program for ATM machine
    By cplus2x in forum C++ Programming
    Replies: 2
    Last Post: 02-06-2008, 04:35 AM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 01:27 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21