I am getting an error that says [Error] Id returned 1 exit status. Can anybody help me out?
I'm not sure what is wrong with the code. I am very new to C++ and coding in general. If someone could give me a few pointers I would appreciate it!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cctype>
using namespace std;
const double BASIC_CABLE = 43.00;
const double PREF_CABLE = 58.00;
const double HBO_CHAN = 9.99;
const double EMP_DISC = .14;
const double BOX_FEE_PREM = 11.25;
const double BOX_FEE_BASIC = 7.50;
const int MIN_NO_BOXES = 2;
const int MAX_NO_BOXES = 4;
double xtraBoxesFeeFunc(int numOfExtra, double serviceType);
int main()
{
string custID;
double subTotal;
char servLevel; // service level
double servLevelPrice;
int cablBoxs;
double xtraBoxCharge;
int xtraBoxs;
bool hasPremium;
char addPremiumChar;
double addedCharge = 0;
int costPremChan;
string employStatus; //employee status
double totalBill;
double totalDisc;
// gets the necessary input from the user
cout << "Please enter your customer ID: " ;
cin >> custID;
cout << endl;
cout << "Please enter your service level ([B]asic, [P]referred)? ";
cin >> servLevel;
cout << endl;
// determines the service price
servLevel = toupper(servLevel);
if (servLevel == 'B')
{
servLevelPrice = BASIC_CABLE;
}
else if (servLevel = 'P')
{
servLevelPrice = PREF_CABLE;
}
// asks user about number of cable boxes and if they get premium channels
cout << "How many cable boxes do you have? ";
cin >> cablBoxs;
cout << endl;
cout << "H = HBO premium channels" << endl;
cout << endl;
cout << "N = No premium channels" << endl;
cout << endl;
cout << "Premium Channels (H/N)? ";
cin >> addPremiumChar;
cout << endl;
cout << endl;
// If the user does get premium channels, this calculates the additional
// charges for them.
if ((addPremiumChar =='H') || (addPremiumChar == 'h'))
{
hasPremium = true;
}
if (hasPremium = true)
{
addedCharge = 9.99;
}
//Outputs the information back to the user
cout << "CableTastic employee? (yes or no, all lowercase): " ;
cin >> employStatus;
cout << endl << endl;
cout << setw(25) << "CABLETASTIC MONTHLY CABLE BILL" << endl << endl;
cout << "Customer Id:" << setw(15) << custID << endl;
cout << "Service:" << setw(15) << servLevel << endl;
cout << "Cable Boxes:" << setw(11) << cablBoxs << endl << endl;
//Warns the user if they have more than 4 boxes and tells them they can
// have two boxes for free if they have less than 2.
if (cablBoxs > MIN_NO_BOXES)
{
cout << setw(25) << "WARNING:" << endl;
cout << setw(71)
<< "Using more than 4 cable boxes may degrade your signal." << endl <<
endl;
}
else if (cablBoxs < MAX_NO_BOXES )
{
cout << "Note: Currently you have less than 2 cable boxes." << endl;
cout << "You may have up to 2 cable boxes for free." << endl << endl;
}
//Calculates the charges for any boxes over 2.
if (cablBoxs > MIN_NO_BOXES && hasPremium == true)
{
xtraBoxs = cablBoxs - MIN_NO_BOXES;
xtraBoxCharge = xtraBoxesFeeFunc(xtraBoxs, BOX_FEE_PREM);
}
else if (cablBoxs > MIN_NO_BOXES )
{
xtraBoxs = cablBoxs - MIN_NO_BOXES;
xtraBoxCharge = xtraBoxesFeeFunc(xtraBoxs, BOX_FEE_BASIC);
}
//Calculates the subtotal of the invoice.
subTotal = (servLevelPrice + xtraBoxCharge + addedCharge);
// Tests employment status and calculates discount
if ( employStatus == "yes")
{
totalDisc = (EMP_DISC * subTotal);
}
else if (employStatus == "no")
{
totalDisc = 0;
}
//Subtracts the discount from the subtotal.
if (servLevel == 'B')
{
totalBill = subTotal + totalDisc;
}
else if (servLevel == 'P')
{
totalBill = subTotal + totalDisc;
}
//Displays the invoice to the user.
cout << std::showpoint;
cout << "Monthly Rate:" << setw(22) << setprecision(4) <<
servLevelPrice << endl;
cout << "Cable Box Fees:" << setw(20) << setprecision(4) <<
xtraBoxCharge << endl;
cout << "Premium Channels:" << setw(17) << setprecision(3) <<
addedCharge << endl;
cout << setw(36) << "--------" << endl;
cout << "Subtotal:" << setw(26) << setprecision(4) << subTotal << endl;
cout << "Employee Discount:" << setw(16) << setprecision(3) << totalDisc <<
endl;
cout << setw(36) << "--------" << endl;
cout << "Total:" << setw(29) << setprecision(4) << totalBill << endl;
cout << endl << endl;
system ("PAUSE");
return 0;
}
//A function to help calculate the fee for extra boxes.
double xtraBoxesFeeFunc(int numOfExtra, double serviceType)
{
numOfExtra * serviceType;
}
|
you are not returning a value on function at line 166
add return on line 168:
return(numOfExtra * serviceType);
There may be other issues but that stands out to me :)
^^That was it!! Thank you so much, I've been staring at this for a few hours now haha.
Your welcome :)
Topic archived. No new replies allowed.