functions interfering with program inputs

Can someone please tell me why this program is not working as it should and why it does not let me type in any inputs after service level.

#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;

// declare variables and constants
int B;
int b;
int cable_box;
int hasHBO;
double cable_box_fee;
double employee_discount;
char cabletastic_employee;
int customer_ID;
int service_level;
double subtotal;
double total;
string yes;
int H;
int h;


//header for use later
void header()
{
cout << left << setw(10);
cout << " CableTastic Bill Calculation Program";
}

// user defined function for cable box fee
void cablebox_fee()
{
if (cable_box < 2){
cout << " Note: Currently you have less than 2 cable boxes." << endl;
cout << left << setw(10);
cout << " You may have up to two cable boxes for free." << endl;
}
else if (cable_box > 4){
cout << " Warning : Using more than 4 cable boxes may degrade your signal";
cout << endl;
}

if (cable_box > 2)
if (B = service_level)
cable_box_fee = cable_box * 7.50;
else if (b = service_level)
cable_box_fee = cable_box * 7.50;
else
cable_box_fee = cable_box * 11.25;
}

int main()
{


//input
//************************************************************
cout << " Enter the customer id: ";
cin >> customer_ID;

//enter "B" for basic or "P" for preferred
cout << endl << " Service level ([B]asic, [P]referred)? ";
cin >> service_level;
cout << endl << endl;

cout << " Enter the number of cable boxes: ";
cin >> cable_box;
cout << endl << endl;

cout << " H = HBO channels" << endl;
cout << " N = No premium chanels" << endl;
cout << " Premium chanels (H/N)? ";
cin >> hasHBO;
cout << endl << endl;

cout << " Cabletastic employee? (yes or no, all lowercase): ";
cin >> cabletastic_employee;


//************************************************************
//other calculations
//service level
{
if (B = service_level)
service_level = 43.00;
else if (b = service_level)
service_level = 43.00;
else
service_level = 58.00;
}
//call user defined function
cablebox_fee;

//Premium chanels
{
if (H = hasHBO)
hasHBO = 9.99;
else if (h = hasHBO)
hasHBO = 9.99;
}
//Cabletastic employee
{
if (cabletastic_employee == 'yes')
employee_discount = (service_level + cable_box_fee + hasHBO)/.14;
else
employee_discount = 0.00;
}

//subtotal
subtotal = (service_level + cable_box_fee + hasHBO);

//total
total = subtotal + employee_discount;


system("cls");

//output
//outputs above header
header();

cout << " Customer Id:" << left << setw (10);
cout << customer_ID << endl;

cout << " Service:" << left << setw(10);
cout << service_level << endl;

cout << " Cable Boxes:" << left << setw(10);
cout << cable_box << endl << endl;

cout << " Monthly Rate:" << left << setw(10);
cout << service_level << endl;

cout << " Cable Box Fee:" << left << setw(10);
cout << cable_box_fee << endl;

cout << " Premium channels:" << left << setw(10);
cout << hasHBO << endl;

cout << right << setw(25) << "--------" << endl;

cout << " Subtotal:" << left << setw(10);
cout << subtotal << endl;

cout << " Employee Discount:" << left << setw(10);
cout << employee_discount << endl;

cout << right << setw(25) << "--------"<< endl;

cout << " Total:" << left << setw(10);
cout << total;

system("pause");
}
Sample output:

 Enter the customer id: 3

 Service level ([B]asic, [P]referred)? 2


 Enter the number of cable boxes: 3


 H = HBO channels
 N = No premium chanels
 Premium chanels (H/N)? 4


 Cabletastic employee? (yes or no, all lowercase): re
 CableTastic Bill Calculation Program Customer Id:3
 Service:43
 Cable Boxes:3

 Monthly Rate:43
 Cable Box Fee:0
 Premium channels:9
                 --------
 Subtotal:52
 Employee Discount:0
                 --------
 Total:52


Seems to let me input after service level.

Top tip; = is an assignment of value. == is a logical test for equality.
Last edited on
OK, I too get the program to prompt all the way through as long as I don't use the "b" or "p" for service level or the "h" or "n" for premium channels, but when I use any of those it skips asking for anything after that.
Note that service_level is an int.

How many chars are in the word "yes", and how many char values does cabletastic_employee represent?

I see you create a string called yes but never use it. That can be removed, since it's never used.
Last edited on
Topic archived. No new replies allowed.