Thread: New to programming, this should be an easy one for you guys

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    15

    New to programming, this should be an easy one for you guys

    I'm just starting to learn programming, and I ran in to a problem very early in my program (not complete yet). The first thing that I prompt the user for is the month, and that works fine. However it doesn't keep working after that, instead of just asking the user for the number of cookies made, it outputs the messages asking for the next 3 variables and then completes, so no other variables are entered. I'm stumped and I'm hoping that you can help me to get over this first obsticle so that I can continue working on my program.

    code:

    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
      int month;
      int cook_made;
      int reg_price;
      int dis_price;
    
      cout << "Enter the first three characters of the month:  ";
      cin >> month;
      cout << "Enter the number of cookies made:  ";
      cin >> cook_made;
      cout << "Enter the regular price for a box of cookies:  ";
      cin >> reg_price;
      cout << "Enter the discount price for a box of cookies:  ";
      cin >> dis_price;
    
      return (0);
    }
    and what I get when I run the program:

    bash-3.00$ ./a.out
    Enter the first three characters of the month: Dec
    Enter the number of cookies made: Enter the regular price for a box of cookies: Enter the discount price for a box of cookies: bash-3.00$

  2. #2
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    You cannot store a string in an int.
    Kurt

  3. #3
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Are you aware that you are asking for the month in a numerical format? It matters.

    Say "Enter the month: (mm) " it will work better.

  4. #4
    Registered User
    Join Date
    Sep 2012
    Posts
    15
    i got this resolved, thanks for the help guys!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How you guys learn programming?
    By xeon321 in forum C Programming
    Replies: 22
    Last Post: 06-16-2012, 08:56 AM
  2. OK. new easy question for you guys.
    By arnis in forum C++ Programming
    Replies: 8
    Last Post: 07-17-2003, 09:52 PM
  3. How do you guys go about programming when you don't feel like programming
    By Silvercord in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 03-04-2003, 05:36 AM
  4. Just to let you guys know about a new Programming Newsletter
    By webmaster in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 12-26-2001, 10:58 PM