Having problems writing

Having a bit of trouble getting this to show up right on the output. Let me know what you come up with.
To me it was a bit challenging and I still cannot get the billing information to come up.. Looking forward to seeing what you guys come up with!


This programming example calculates a customer’s bill for a local cable company
There are two types of customers:
Residential
Business
Two rates for calculating a cable bill:
One for residential customers
One for business customers

For residential customer:
Bill processing fee: $4.50
Basic service fee: $20.50
Premium channel: $7.50 per channel

For business customer:
Bill processing fee: $15.00
Basic service fee: $75.00 for first 10 connections and $5.00 for each additional connection
Premium channel cost: $50.00 per channel for any number of connections

Assume R or r stands for residential customer and B or b stands for business customer

Input:
Customer account number
Customer code
Number of premium channels
For business customers, number of basic service connections

Output:
Customer’s account number
Billing amount

Purpose: calculate and print billing amount
Calculating billing amount requires:
Customer for whom the billing amount is calculated (residential or business)
Number of premium channels to which the customer subscribes

For a business customer, you need:
Number of basic service connections
Number of premium channels

Data needed to calculate the bill, such as bill processing fees and the cost of a premium channel, are known quantities
The program should print the billing amount to two decimal places

Set precision to two decimal places
Prompt user for account number and customer type
If customer type is R or r
Prompt user for number of premium channels
Compute and print the bill
If customer type is B or b
Prompt user for number of basic service connections and number of premium channels
Compute and print the bill

[IMG]http://i198.photobucket.com/albums/aa308/tristascorner/Picture2.png[/IMG]
[IMG]http://i198.photobucket.com/albums/aa308/tristascorner/Picture1.png[/IMG]

Formulas to use:

Billing for residential customers:

amountDue = RES_BILL_PROC_FEES +
RES_BASIC_SERV_COST
+ numOfPremChannels *
RES_COST_PREM_CHANNEL;



Billing for business customers:

if (numOfBasicServConn <= 10)
amountDue = BUS_BILL_PROC_FEES +
BUS_BASIC_SERV_COST
+ numOfPremChannels *
BUS_COST_PREM_CHANNEL;
else
amountDue = BUS_BILL_PROC_FEES +
BUS_BASIC_SERV_COST
+ (numOfBasicServConn - 10)
* BUS_BASIC_CONN_COST
+ numOfPremChannels *
BUS_COST_PREM_CHANNEL;



Output floating-point numbers in fixed decimal with decimal point and trailing zeros
Output floating-point numbers with two decimal places and set the precision to two decimal places
Prompt user to enter account number
Get customer account number
Prompt user to enter customer code
Get customer code

If the customer code is r or R,
Prompt user to enter number of premium channels
Get the number of premium channels
Calculate the billing amount
Print account number and billing amount

If customer code is b or B,
Prompt user to enter number of basic service connections
Get number of basic service connections
Prompt user to enter number of premium channels
Get number of premium channels
Calculate billing amount
Print account number and billing amount

If customer code is other than r, R, b, or B, output an error message
You need to show us what you have so far before we will help you with your homework.
I'm sorry.. This is what I have so far. But nothing past the questions I can see to get right..


#include <iostream>
using namespace std;

int main()
{
int accountNumber; //cutomer's account number
int r, R, b, B;
int numOfPremChannels; //number of premium channels
int numOfBasicServConn; //number of basic connections
char customerType; //customer code
double amountDue; //billing amount
//Named constants - residential customers
const double RES_BILL_PROC_FEES = 4.50;
const double RES_BASIC_SERV_COST = 20.50;
const double RES_COST_PREM_CHANNEL = 7.50;
//Named constatns - business cutomers
const double BUS_BILL_PROC_FEES = 15.00;
const double BUS_BASIC_SERV_COST = 75.00;
const double BUS_BASIC_CONN_COST = 5.00;
const double BUS_COST_PREM_CHANNEL = 50.00;

cout << " Please enter your account number:"<< endl;
cin >> accountNumber;


cout << " Residential or Business:" << endl;
cout << " r for residential, b for business." << endl;
cin >> customerType, r, b;

cout << " Please enter the number of premium channels: " << endl;
cin >> numOfPremChannels;

cout << " Please enter your basic service connection: " << endl;
cin >> numOfBasicServConn;



cout << " --------------------" << endl;
cout << "Your Account number is: " << accountNumber << endl;
cout << " Your service type is :";



if
(numOfBasicServConn <= 10);
{
cout << " Number of Basic Service Connection:"<< endl;
cin >> amountDue = BUS_BILL_PROC_FEES +
BUS_BASIC_SERV_COST
+ numOfPremChannels *
BUS_COST_PREM_CHANNEL;

else
amountDue = BUS_BILL_PROC_FEES +
BUS_BASIC_SERV_COST
+ (numOfBasicServConn - 10)
* BUS_BASIC_CONN_COST
+ numOfPremChannels *
BUS_COST_PREM_CHANNEL;


if (r)

amountDue = RES_BILL_PROC_FEES +
RES_BASIC_SERV_COST
+ numOfPremChannels *
RES_COST_PREM_CHANNEL;












system("PAUSE");
return 0;
}

Thanks for posing the code. Next time you post code, please use the code tags. They show up as "<>" in the Format box to the right of the input box, and make it a lot easier to read your code.

I think the first thing you need to do is do things in very simple steps. Try one thing, and test it to make sure it works. Start with just inputting the account number and printing it back to the screen. (I think you have that one correct).

Next input the customer type and print it to the screen. This one you messed up. There is only one customer type for the user. This is the customerType variable. This variable will contain either the character value 'r' or 'b', but you do not need additional variables with those names. Said another way: The user will type either 'r' or 'b' which will be stored in customerType--the variables r and b are wrong and will screw up your input statement:
cin >> customerType

Keep working on your program in little steps, verifying it as you go. So make sure you can read and write the account number and the customer type before you go on.


Something I noticed: In the statement:

1
2
3
4
cin >> amountDue = BUS_BILL_PROC_FEES +
    BUS_BASIC_SERV_COST
    + numOfPremChannels *
    BUS_COST_PREM_CHANNEL;


you have some problems. Your cin function will read in the value of a variable, but not into an assignment statement that you have. I don't think you want the cin. You probably want to calculate amountDue from the values you have there.

The cin function lets you ask the user for a value. Don't use it to assign calculated values.

So have fun. Remeber--work in small steps. As you become more fluent in C++ and better understand what the errors are that you encounter, you can begin to make your steps a little bigger. But as a beginner, you should make sure simple code works as expected before adding more to it.
Topic archived. No new replies allowed.