Monday, May 24, 2010

Ok... i wrote it... now need help completing it (c++)?

i need to times the amount of adult tickets with $6.00 and the amount of child tickets with $3.00. Then i need to add those two together. where do i need to add the info? and what is that info%26gt;?


#include %26lt;cstdlib%26gt;


#include %26lt;iostream%26gt;





using namespace std;





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


{


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





char moviename[50], adult[50], child[50];


int Six,Three,Total;





cout %26lt;%26lt; "" %26lt;%26lt; endl;





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


cin.get(moviename,50);


cout %26lt;%26lt; "" %26lt;%26lt; endl;


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


cin %26gt;%26gt; adult;


cout %26lt;%26lt; "" %26lt;%26lt; endl;


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


cin %26gt;%26gt; child;


cout %26lt;%26lt; "" %26lt;%26lt; endl;





cout %26lt;%26lt; "***************************************... %26lt;%26lt; endl;


cout %26lt;%26lt; "" %26lt;%26lt; endl;


cout %26lt;%26lt; "INCOME STATEMENT" %26lt;%26lt; endl;


cout %26lt;%26lt; "******************" %26lt;%26lt; endl;





cout %26lt;%26lt; "" %26lt;%26lt; endl;


cout %26lt;%26lt; "Movie Name: "%26lt;%26lt;moviename%26lt;%26lt; endl;


cout %26lt;%26lt; "Adult Tickets Sold: "%26lt;%26lt;adult %26lt;%26lt; endl;


cout %26lt;%26lt; "Child Tickets Sold: "%26lt;%26lt;child%26lt;%26lt; endl;


cout %26lt;%26lt; "Gross Box Office Profits: " %26lt;%26lt;endl;


cout %26lt;%26lt; "Net Box Office Profit: " %26lt;%26lt; endl;


cout %26lt;%26lt; "Amount Paid To Distributers" %26lt;%26lt; endl;


cout %26lt;%26lt; " " %26lt;%26lt; endl;


























system("PAUSE");


return EXIT_SUCCESS;


}

Ok... i wrote it... now need help completing it (c++)?
add anywhere after the cin





int childDollars = child * 3;


int adultDollars = adult *6;








then cout them as you did the rest.
Reply:programming is done well but wat bout mathematics.


you made no. of tickets variable as adult and child but they are character variables made them integer





then calculate total


use arithmetic to solve that
Reply:Gee, haven't done some C++ programming for a long while (like, maybe four years). But I do get the logic of your program, all you need to do is create three additional variables for the data that you need %26amp; create a formula.





Let's call them AdultSales, ChildSales %26amp; GrossSales. You declare them along with your variables for the tickets, like this:





int Six,Three,Total,AdultSales,ChildSales,Gr...








Then you create the formula:





AdultSales = adult*6;


ChildSales = child*6;


GrossSales = AdultSales + ChildSales;





Be sure to insert this formula expression before your code for screen output.








Then you modify you code for your output:





. . . . .


cout %26lt;%26lt; "Adult Tickets Sold: "%26lt;%26lt;adult %26lt;%26lt; endl;


cout %26lt;%26lt; "Child Tickets Sold: "%26lt;%26lt;child%26lt;%26lt; endl;


cout %26lt;%26lt; "Gross Box Office Profits: "%26lt;%26lt;GrossSales %26lt;%26lt;endl;


. . . . .








Hope that solves your problem.


No comments:

Post a Comment