Friday, July 31, 2009

Programming Question (C++)?

So im in a intro to programming class. I wrote a program and it runs, but not the way i want.


My code is:





#include %26lt;cstdlib%26gt;


#include %26lt;iostream%26gt;





using namespace std;





int main(int argc, char *argv[])


{


cout %26lt;%26lt; "This program was written by Jacob A. DePratti" %26lt;%26lt; endl;


double name, adult, child;





cout %26lt;%26lt; "Enter the movie's Name: ";


cin %26gt;%26gt; name;


cout %26lt;%26lt; "Enter the number of adult tickets sold: " %26lt;%26lt; endl;


cin %26gt;%26gt; adult;


cout %26lt;%26lt; "Enter the number of child tickets sold: " %26lt;%26lt; endl;


cin %26gt;%26gt; child;

















system("PAUSE");


return EXIT_SUCCESS;








I can type in the title of a movie. But then I cant plug in the numbers for adults and kids. also how can i get then to come up seprately. so...


Name of movie? (ENTER NAME) , click and then it goes to


Number of Adults attending (ENTER AMOUNT) click and then it goes


Number of kids attending (ENTER AMOUNT) CLICK then done

Programming Question (C++)?
use char name[];


double adult,child;


it will work
Reply:You should make the variable 'name' a string type. Double is an integer type.
Reply:replace the line which declares the variables....





instead of "double name, adult, child;"





use this...


...................





string name;


double adult, child;





...................


since it's c++, use string class...


later you will learn more about this and how to handle strings...
Reply:name variable should be char name[MAX_MOVIE_LENGTH];


or add MFC support to your project and use String name;


No comments:

Post a Comment