control flow question?

This is a discussion on control flow question? within the C++ Programming forums, part of the General Programming Boards category; I have to make the following program: the user must input day and month, and the program to display which ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    10

    control flow question?

    I have to make the following program: the user must input day and month, and the program to display which season is with words "winter" "spring" "summer" fall"

    What i do is

    Code:
    #include <iostream>
    #include <string>
    #include <cmath>
    using namespace std;
    
    int main()
    
    {
        int day, month;
        cin >> day >> "Please enter a date:\n";
        cin >> month >> "now enter a month:\n";
    
        switch (month)
        {
        case 1 : cout << "winter"; break;
        case 2 : cout << "winter"; break;
        case 3 : if (day<=19)
            {cout << "winter";
                    else << "spring"}; break;
        }
    
    
    return 0;
    
    }
    where i fail?is this a right approach?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,886
    For one thing, you probably want to use cout to print those strings (e.g., "Please enter a date:\n") instead of trying to use cin to read into them.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    10
    Quote Originally Posted by laserlight View Post
    For one thing, you probably want to use cout to print those strings (e.g., "Please enter a date:\n") instead of trying to use cin to read into them.
    Thanks a lot, i've solved the problem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Design layer question
    By mdoland in forum C# Programming
    Replies: 0
    Last Post: 10-19-2007, 04:22 AM
  2. Exam Question - Possible Mistake?
    By Richie T in forum C++ Programming
    Replies: 15
    Last Post: 05-08-2006, 03:44 PM
  3. Updating a list control
    By MPSoutine in forum Windows Programming
    Replies: 2
    Last Post: 12-05-2003, 01:03 AM
  4. Lame question on dialog controls appearance
    By Templario in forum Windows Programming
    Replies: 2
    Last Post: 03-18-2003, 07:22 PM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 02:57 PM

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