Show for session:
1. 2pm- 4pm
2. 8pm- 10pm

1
--------------------------------------------------------------------------------------------------
Enter number of adult customers
2
Enter number of child customers
1
The receipt for the purchase is:

Adult 2 20.00
Children 1 5.00
TOTAL 25.00
Press Y to continue

Y
---------------------------------------------------------------------------------------------------
Enter number of adult customers
2
Enter number of child customers
2
The receipt for the purchase is:

Adult 2 20.00
Children 2 10.00
TOTAL 30.00
Press Y to continue

Y
Reached maximum capacity of this session!!!
The total amount of sales today is 450.00
System exit……

Dani AI

Generated

For : a focused, ready-to-run C++ approach follows. It shows a session menu, validates numeric input, prevents selling more seats than remain, prints a two-decimal receipt, and accumulates total sales across runs. Thanks to for the nudge; as warned, sharing constraints and attempted code helps—this example is self-contained and easy to adapt.

Key points implemented: keep prices and capacities as constants at the top; read integers with a safe input helper that rejects negatives and bad input; check that requested seats do not exceed remaining seats; format money with fixed + setprecision(2). For strict monetary accuracy use integer cents instead of double.

#include <iostream>
#include <iomanip>
#include <limits>
#include <cctype>
#include <string>

int safeInt(const std::string &prompt) {
    int x;
    while (true) {
        std::cout << prompt;
        if (std::cin >> x && x >= 0) {
            std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
            return x;
        }
        std::cout << "Please enter a non-negative integer.\n";
        std::cin.clear();
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    }
}

int main() {
    const int NUM_SESSIONS = 2;
    int remaining[NUM_SESSIONS] = {20, 20}; // adjust capacities
    const double ADULT_PRICE = 10.0;
    const double CHILD_PRICE = 5.0;
    double totalSales = 0.0;

    while (true) {
        std::cout << "Sessions:\n1) Afternoon\n2) Evening\nSelect session (1-" << NUM_SESSIONS << ") or 0 to quit: ";
        int s;
        if (!(std::cin >> s)) { std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); continue; }
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        if (s == 0) break;
        if (s < 1 || s > NUM_SESSIONS) { std::cout << "Invalid session number.\n"; continue; }
        int idx = s - 1;
        if (remaining[idx] == 0) { std::cout << "Session is sold out.\n"; continue; }

        while (remaining[idx] > 0) {
            int adults = safeInt("Enter number of adults: ");
            int children = safeInt("Enter number of children: ");
            int req = adults + children;
            if (req == 0) { std::cout << "No tickets requested. Try again.\n"; continue; }
            if (req > remaining[idx]) { std::cout << "Only " << remaining[idx] << " seats remaining. Please reduce the number.\n"; continue; }

            double sale = adults * ADULT_PRICE + children * CHILD_PRICE;
            std::cout << std::fixed << std::setprecision(2);
            std::cout << "\nReceipt:\nAdults: " << adults << "  " << adults*ADULT_PRICE << "\n";
            std::cout << "Children: " << children << "  " << children*CHILD_PRICE << "\n";
            std::cout << "TOTAL: " << sale << "\n\n";

            remaining[idx] -= req;
            totalSales += sale;
            if (remaining[idx] == 0) { std::cout << "Session sold out.\n"; break; }

            char c;
            std::cout << "Continue selling for this session? (y/N): ";
            if (!(std::cin >> c)) break;
            std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
            if (std::tolower(static_cast<unsigned char>(c)) != 'y') break;
        }
    }

    std::cout << std::fixed << std::setprecision(2) << "Total sales: " << totalSales << "\n";
    return 0;
}

Notes: test boundary cases (zero, exact remaining seats, invalid input). Replace capacities and prices at the top to match the required business rules. Using integer cents (store amounts as whole integers) avoids floating-point rounding if exact currency math is required.

Recommended Answers

All 5 Replies

You shouldn't ask you question only in the title, but i'll make an exception.
>please can any1 help me with this program
The answer is yes, I can help you with this program. Hope I was able to help!

commented: Nice response :) +36

You shouldn't ask you question only in the title, but i'll make an exception.
>please can any1 help me with this program
The answer is yes, I can help you with this program. Hope I was able to help!

i'm sorry i don't meant that.....
pls really need help..

Do you go to an auto repairman and say "my car is broke -- please fix it. And BTW I left my car at home." No of course you don't. You have to take your car there and tell him what you think is the problem. Same here. We can't help you id you don't tell us what you need help doing and post the code that you tried. Afterall, we can't read your mind and certainly can't see your monitor.

And if you think we will write the program for you -- forget it because we won't.

Do you go to an auto repairman and say "my car is broke -- please fix it. And BTW I left my car at home." No of course you don't. You have to take your car there and tell him what you think is the problem. Same here. We can't help you id you don't tell us what you need help doing and post the code that you tried. Afterall, we can't read your mind and certainly can't see your monitor.

And if you think we will write the program for you -- forget it because we won't.

come on pls........it's in c++

commented: Loser, go make your own homework! -3

thread closed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.