help with a basic c++ issue

Discussion in 'C Programming' started by cougar, Feb 23, 2008.

  1. cougar

    cougar

    Joined:
    Feb 23, 2008
    Messages:
    1
    Visual Studio 6.0 C++ w/sp6

    Problem possibly with how compiler reads getline. I assume getline is not reading end of line.

    I prompt to enter the name of the movie. After inputting the name of the movie, I press enter. Cursor goes to next line and waits for me to press the <enter> key and then it goes on with the program. To test in a different program, I wrote a simple program to display output and in my first cout statement (exact same spot of this program with trouble) - after the semicolon, I pressed enter and it indented the next line. Normally, it'll go to the beginning of the next line but it didn't.

    Here is my program. Any help would be appreciated.

    // This program will calculate a theater's gross and net box office profit for 1 night.
    // This program will display the movie name, child and adult tickets sold, gross and net
    //profit and amount paid to distributor.

    #include <iostream>
    #include <string>
    #include <iomanip>
    using namespace std;

    int main()
    {
    string movieTitle;
    int a_sold, c_sold;
    double a_total, c_total, gross, net, dist;
    const double APRICE = 6.00, CPRICE = 3.00;

    cout << "Enter the name of the movie " << endl;
    getline(cin, movieTitle);
    cout << "Enter the number of Adult tickets sold " << endl;
    cin >> a_sold;
    cout << "Enter the number of Child tickets sold " << endl;
    cin >> c_sold;

    a_total = APRICE * a_sold;
    c_total = CPRICE * c_sold;
    gross = a_total + c_total;
    dist = gross * .8;
    net = gross * .2;

    cout << "Movie Title " << movieTitle << endl;
    cout << "Adult Tickets Sold " << a_sold << endl;
    cout << "Child Tickets Sold " << c_sold << endl;
    cout << "Gross Box Office Profit " << gross << endl;
    cout << "Amount Paid to Distributor " << dist << endl;
    cout << "Net Box Office Profit " << net << endl;

    return 0;

    }
    cougar, Feb 23, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jim

    basic thread issue

    jim, Jan 23, 2004, in forum: Java
    Replies:
    15
    Views:
    646
    Chris Uppal
    Jan 26, 2004
  2. Marco
    Replies:
    11
    Views:
    579
    Marco
    Apr 4, 2004
  3. Engineer
    Replies:
    6
    Views:
    606
    Jeremy Bowers
    May 1, 2005
  4. rrr@ronadam.com
    Replies:
    0
    Views:
    418
    rrr@ronadam.com
    May 2, 2005
  5. Srini
    Replies:
    11
    Views:
    955
    Arne Vajhøj
    Jun 1, 2008
Loading...

Share This Page