我的手机账单项目C ++存在问题 [英] I have an issue with my cell phone bill project C++

查看:69
本文介绍了我的手机账单项目C ++存在问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户选择常规电话帐单服务时,似乎会出现问题,但它没有提供正确的输出。高级电话费对我有用,唯一棘手的泡菜是普通电话费服务。



我尝试过:



The issue seems to arise when the user select the regular phone bill service it doesn't give a proper output. The premium phone bill worked for me the only tricky pickle is the regular phone bill service.

What I have tried:

#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;

   }



}

推荐答案

10.00加50分钟免费。超过50分钟的费用是
10.00 plus 50 minutes are free. Charges for over 50 minutes are


.20每分钟。

高级服务:
.20 per minute. Premium service:


25.00 plus:

a。对于上午6:00至下午6:00之间的通话,前75分钟是免费的;超过75分钟的费用是
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


这篇关于我的手机账单项目C ++存在问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆