help with a basic c++ issue

Joined
Feb 23, 2008
Messages
1
Reaction score
0
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;

}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top