0

I have a problem with my program and I would appreciate help.

It's supposed to allow you to enter an account number, a service code, and the number of minutes the service was used. The program then calculates the bill and it varies depending on your service. When I execute the program, it doesn't allow you to enter anything.

Regular service:$10.00 plus first 50 minutes free. Charges for over 50 minutes are $0.20 per minute.

Premium service: $25.00 plus: a) For calls made from 6:00 am to 6:00 pm, the first 75 minutes are free; charges for over 75 minutes are $0.10 per minute. b)For calls made from 6:00 pm to 6:00 am, the first 100 minutes are free; charges for over 100 minutes are $0.05 per minute.

Here is the program that I've typed.

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main()
{
int minutes = 0,
    day_minutes = 0, //minutes used during the day
    night_minutes = 0; //minutes used during the night
string service_code,
       account_number;
double final_amount,
       final_damount,    //final amount for day minutes
       final_namount = 0; //final amount for night minutes


cout << "Please enter your account number: "; 
cin >> account_number;
cout << "Please enter your service code (r or R for regular service and p or P for premium service): "; 
cin >> service_code; 
if (service_code == "r")
{
    cout << "Please enter the amount of minutes used: " << minutes << endl;
}
if (minutes <= 50)
{
    final_amount = 10;
    cout << "Your final amount is $: " << final_amount << endl;
}
if (minutes > 50)
{
final_amount = (minutes * 0.20) + 10;
cout << "Your final amount is $: " << final_amount << endl;
}
else if (service_code == "p")
{
cout << "Please enter the amount of minutes used during the day: " << day_minutes << endl;
        cout << "Please enter the amount of minutes used during the night: " << night_minutes << endl;
}
if (day_minutes <=75)
{
    final_damount = 0;
    final_amount = final_damount + final_namount + 20;
}
if (day_minutes > 75)
{
    final_damount = day_minutes * 0.10;
    final_amount = final_damount + final_namount + 20;
}
if (night_minutes <= 100)
{
    final_namount = 0;
    final_amount = final_damount + final_namount + 20;
}
if (night_minutes > 100)
{
    final_namount = night_minutes * 0.05;
    final_amount = final_damount + final_namount + 20;
    cout << "Your final amount is: $ " << final_amount << endl;
}
else 
    cout << "Error, this program does not accept negative numbers.\n";


return 0;
}

Does anyone the problem to my program? Thank you.

5
  • 1
    What have you even tried? what happens? Have you tried using a debugger? Commented Apr 4, 2014 at 20:37
  • Which part, exactly, do you expect to let you enter anything? Commented Apr 4, 2014 at 20:38
  • This is a great reason why you need to reduce problems to the smallest subset that is effective and ask a question at the start and use an appropriate name.. Commented Apr 4, 2014 at 20:42
  • It's supposed to let you input it where it says: Please enter your account number and service code. Commented Apr 4, 2014 at 20:52
  • Now it's letting me enter the account number and service code, but it's not letting me enter the minutes or calculate the bill. Commented Apr 4, 2014 at 20:59

1 Answer 1

3

In your code you never specify to ask for user input (read from any input streams or files), hence it doesn't ask for any input.

You will probably want to somewhere do something such as cin or cin.readline or any of several other various methods to read the user's input from stdin.

To avoid duplicating other questions I'm not putting further details here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.