У меня есть проблема с моим проектом счета за сотовый телефон c++
Проблема, по-видимому, возникает, когда пользователь выбирает обычную услугу оплаты телефонных счетов, она не дает должного результата. Премиальный телефонный счет сработал для меня, единственный хитрый рассол - это обычная услуга по оплате телефонных счетов.
Что я уже пробовал:
#include <iostream> #include <iomanip> //Made By Lee Rankin /* Write a program that calculates and prints the bill for a cell phone company. The company offers two types of service: regular and premium. Its rates vary, depending on the type of service. The rates are computed as follows: Regular service: $10.00 plus 50 minutes are free. Charges for over 50 minutes are $.20 per minute. Premium service: $25.00 plus: a. For calls made from 6:00 a.m. to 6:00 p.m., the first 75 minutes are free; charges for over 75 minutes are $0.10 per minute. b. For calls made from 6:00 p.m. to 6:00 a.m., the first 100 minutes are free; charges for over 100 minutes are $0.05 per minute. Your program should prompt the user to enter an account number, a service code (type char), and the number of minutes the service was used. A service code of R or r means regular service; a service code of P or p means premium service. Treat any other character as an error. Your program should output the account number, type of service, number of minutes the telephone service was used, and the amount due from the user. For the premium service, the customer may be using the service during the day and the night. Therefore, to calculate the bill, you must ask the user to input the number of minutes the service was used during the day and the number of minutes the service was used during the night. */ using namespace std; int account_number; float minutes; char service; float amount_due; float daymin; float nightmin; float regular(); float premium(); int main() { cout << "Enter an account number:" << endl; cin >> account_number; cout << "Enter R or r for regular service. Enter P or p for premium service." << endl; cin >> service; //for regular accounts if (service == 'r' || service == 'R') regular(); //for premium accounts else if (service == 'p' || service == 'P') premium(); else { cout << "Invalid entry." << endl; //if user does not enter regular or premium account } //For output return 0; } float premium() { cout << "Enter minutes of calls made between 6:00 a.m. to 6:00 p.m." << endl; cin >> daymin; cout << "Enter minutes of calls made between 6:00 p.m. to 6:00 a.m." << endl; cin >>nightmin; if (daymin > 75) { amount_due = ((daymin - 75) * .10); } if (nightmin > 100) { amount_due = ((daymin - 100) * .05); } amount_due = amount_due + 25.00; cout << "Account number " << account_number << " with premium service. Total minutes: " << (daymin+nightmin) << " Total Bill $" << fixed << setprecision(2) << amount_due << endl; } float regular () { cout << "Enter the number of minutes used." << endl; cin >> minutes; if (minutes <= 50.00) { amount_due = 10.00; cout << "Account number " << account_number << " with regular service. Total minutes: " << minutes << " Total Bill $" << fixed << setprecision(2) << amount_due << endl; } else { amount_due = ((minutes -50.00) * 0.20); cout << "Account number " << account_number << " with regular service. Total minutes: " << minutes << " Total Bill $" << fixed << setprecision(2) << amount_due << endl; } }