Computers

posted by .

Can someone please tell me what I'm doing wrong?


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

int main()
{
//....

//Constants for adult and child ticket costs
const double cost_per_child_tix = 3;
const double cost_per_adult_tix = 6;

//Variables
double adult, //Amount of adult tix sold
child, //Amount of child tix sold
movie, //Holds movie name
gross_adult_tix, // Holds gross amount of adult tickets
gross_child_tix, // Holds gross amount of child tickets
total_box_office_profit, //Holds total box office profit
net_box_office_profit, //Holds total earnings for theater
amount_paid_distributor; //Holds final amount paid to distributor

//Set the desired output formatting for numbers.
cout << setprecision(2) << fixed << showpoint;

//Prompt the user for the movies name
cout <<"Please enter name of movie:" << endl;
cin >> movie;
cin.clear();
cin.ignore(256, '\n');

//Get adult tickets sold
cout << "Enter number of adult tickets sold: \n";
cin >> adult;

//Get child tickets sold
cout << "Enter number of child tickets sold: \n";
cin >> child;

//Calculate gross amount for adult tickets sold
gross_adult_tix = adult * cost_per_adult_tix;

//Calculate gross amount of child tickets sold
gross_child_tix = child * cost_per_child_tix;

//Calculate gross box office profit
total_box_office_profit = gross_child_tix + gross_adult_tix;

//Calculate net box office profit (Theater earnings)
net_box_office_profit = total_box_office_profit * .20;

//calculate amount paid to distributor
amount_paid_distributor = total_box_office_profit - net_box_office_profit;

//Display movie name and header for daily earning report
cout << "Daily earnings report for movie:" << movie << endl;

//Display amount of adult tickets sold
cout << "Adult tickets sold:" << adult << endl;

//Display amount of child tickets sold
cout << "Child tickets sold:" << child << endl;

//Display gross amount for box office profit
cout << "Gross box office profit:" << total_box_office_profit << endl;

//Display net gross amount of profit
cout << "Gross net box office profit:" << net_box_office_profit << endl;

//Display amount paid to distributor
cout << "Amount paid to distributor:" << amount_paid_distributor << endl;

//....

return 0;
}

  • C++ debugging -

    If you need to debug a programme, it would help more if you specify:
    1. object of the programme
    2. language (C++ in this case)
    3. What does not work:
    - does not compile? (error message?)
    - does not run ? (error message?)
    - does not give proper answer (logical error)
    - loops indefinitely?
    4. State what you think could be the problem.

    Here are my comments despite the lack of the above information. Start with the comments and please give full information on your next post.

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

    int main()
    {
    //....

    //Constants for adult and child ticket costs
    const double cost_per_child_tix = 3;
    const double cost_per_adult_tix = 6;

    //Variables
    double adult, //Amount of adult tix sold
    // you mean NUMBER of tix sold **********************
    child, //Amount of child tix sold
    // you mean NUMBER of child tix sold ************
    movie, //Holds movie name
    //**** use a string or char* for names ************
    gross_adult_tix, // Holds gross amount of adult tickets
    gross_child_tix, // Holds gross amount of child tickets
    total_box_office_profit, //Holds total box office profit
    net_box_office_profit, //Holds total earnings for theater
    amount_paid_distributor; //Holds final amount paid to distributor

    //Set the desired output formatting for numbers.
    cout << setprecision(2) << fixed << showpoint;

    //Prompt the user for the movies name
    cout <<"Please enter name of movie:" << endl;
    cin >> movie;
    //**** Cannot enter name of a movie into a double ********
    cin.clear();
    cin.ignore(256, '\n');

    //Get adult tickets sold
    cout << "Enter number of adult tickets sold: \n";
    cin >> adult;

    //Get child tickets sold
    cout << "Enter number of child tickets sold: \n";
    cin >> child;

    //Calculate gross amount for adult tickets sold
    gross_adult_tix = adult * cost_per_adult_tix;

    //Calculate gross amount of child tickets sold
    gross_child_tix = child * cost_per_child_tix;

    //Calculate gross box office profit
    total_box_office_profit = gross_child_tix + gross_adult_tix;

    //Calculate net box office profit (Theater earnings)
    net_box_office_profit = total_box_office_profit * .20;
    // I would put 0.20 as a constant or variable ***********


    //calculate amount paid to distributor
    amount_paid_distributor = total_box_office_profit - net_box_office_profit;

    //Display movie name and header for daily earning report
    cout << "Daily earnings report for movie:" << movie << endl;

    //Display amount of adult tickets sold
    cout << "Adult tickets sold:" << adult << endl;

    //Display amount of child tickets sold
    cout << "Child tickets sold:" << child << endl;

    //Display gross amount for box office profit
    cout << "Gross box office profit:" << total_box_office_profit << endl;

    //Display net gross amount of profit
    cout << "Gross net box office profit:" << net_box_office_profit << endl;

    //Display amount paid to distributor
    cout << "Amount paid to distributor:" << amount_paid_distributor << endl;

    //....

    return 0;
    }

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. C++

    Can anyone help me with my c++ program? Its a program I have to write using structs and arrays and i'm stuck. If anyone can help can you post back and I'll show you what i've got and maybe you can tell me why its not working correctly.
  2. C++ Programming

    I have to redo programming exercise 5 of chapter 9 using dynamic arrays. but I have the information but I don't know how to use it in a dynamic arrays please help. //Chapter 9: Programming Exercise 5 #include <iostream> #include …
  3. C++ Programming

    Design and create a class named Stats that has an array of 12 doubles as one of its member variables. The values in the array should be set by making 12 calls to a public member function named setValue that accepts two arguments, an …
  4. C++ if else problem, please look

    It compiles but it doesn't work. can you tell me what i did wrong?
  5. programming C++

    Write a program that reads test scores up to 30 into an array. sentinel will stop when -1 is entered. Write functions that: 1. read the scores into arrays 2. computes the distribution based on whether they are As, Bs and so on 3. find …
  6. computer science

    9.10: Reverse Array Write a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should …
  7. Fund of programming 1

    Complete the following C++ program. The program should compute and output the Celsius value corresponding to the given Fahrenheit value. //************************************************ // Celsius program // This program outputs …
  8. Programing

    Write a full program that reads in an arbitrary sequence of integers from the standard input, and writes them to the standard output in sorted order and with all duplicates removed. You may assume the input contains at most 100 integers …
  9. computer science

    Writing a c++ program that stores the following values in five different variables:28,32,37,24,and 33.We have been ask to get the average of the series of values given above. Here I what I got /// This program calculates the sum and …
  10. c++

    when i compile the following, many erors appear // include necessary libraries #include <iostream> #include <cmath> // use std namespace using namespace std; int main() { // declare the value of PI const double PI = atan( …

More Similar Questions