Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QtCore/QCoreApplication>
- #include <QTextStream>
- #include <cstdlib>
- QTextStream cin(stdin, QIODevice::ReadOnly);
- QTextStream cout(stdout, QIODevice::WriteOnly);
- double computeBill(int hours)
- {
- if (hours <= 3)
- return 2.0;
- else
- {
- int hourDifference = hours-3;
- double totalBill;
- totalBill = (hourDifference * 0.5) + 2;
- if (totalBill <= 10)
- return totalBill;
- else
- return 10.0;
- }
- }
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- int hour1, hour2, hour3;
- double fee1, fee2, fee3, totalFee;
- cout << "Parking Fee Calculator\n\n"
- << "Enter the length of stay for three customers...\n"
- << "Customer 1: ";
- cout.flush();
- cin >> hour1;
- cout << "Customer 2: ";
- cout.flush();
- cin >> hour2;
- cout << "Customer 3: ";
- cout.flush();
- cin >> hour3;
- fee1 = computeBill(hour1);
- fee2 = computeBill(hour2);
- fee3 = computeBill(hour3);
- totalFee = fee1 + fee2 + fee3;
- cout << "\nParking Fees...\n"
- << QString("Customer 1: %1\n").arg(fee1, 0, 'f', 2)
- << QString("Customer 2: %1\n").arg(fee2, 0, 'f', 2)
- << QString("Customer 3: %1\n\n").arg(fee3, 0, 'f', 2)
- << QString("Total Parking fees: %1").arg(totalFee, 0, 'f', 2)
- << endl;
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement