Programming

C# – Billing

July 15, 2015

Hi friends! I’ll post another problem and be sure to stay tuned since it’s quite long to read. Lol 🙂

Create a program that calculates a customer’s bill for a local cable company. There are two types of customers: residential and business. There are two rates for calculating a cable bill: one for residential customer’s and one for business customers.

For residential customers, the following rates apply:

  • Bill processing fee : $4.50
  • Basic service fee : $20.50
  • Premium channels: $7.50 per channel

For business customers, the following rates apply:

  • Bill processing fee : $15.00
  • Basic service fee : $75.00 for first 10 connections, $5.00 for each additional connection
  • Premium channels : $50.00 per channel for any number of connections

The program should ask the user for an account number (an integer) and a customer code.

Assume that R or r stands for a residential customer, and B or b stands for a business customer. The purpose of this program is to calculate and print the billing amount. To calculate the billing amount, you need to know the customer for whom the billing amount is calculated (whether the customer is residential or business) and the number of premium channels to which the customer subscribes in the case of a business customer, you also need to know the number of basic service connections and the number of premium channels. Other data needed to calculate the bill, such as the bill processing fees and cost of a premium channel, are known quantities. The program should print the billing amount to two decimal places, which is standard for monetary amounts.

Input: The customer’s account number, customer name, number of premium channels to which the user subscribes, and , in the case of business customers, the number of basic service connections.

Output: Customer’s account number, customer name and the billing amount.

Residential sample

Residential sample

Business sample

Business sample

The photos above were the output of this source code.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String customername, customercode;
            int numberchannel, connection, accountnumber;
            double amount, fee, basic, premium, temp;
            temp = 0;

            System.Console.Write("Enter Account Number: ");
            accountnumber = Convert.ToInt32(System.Console.ReadLine());

            System.Console.Write("Enter Customer Name: ");
            customername = System.Console.ReadLine();

            System.Console.Write("Enter Customer Code: ");
            customercode = System.Console.ReadLine();

            System.Console.Write("Enter Number of Channel: ");
            numberchannel = Convert.ToInt32(System.Console.ReadLine());
            connection = 0;
            if (customercode == "B")
            {

                System.Console.Write("Enter Number of Connection: ");
                connection = Convert.ToInt32(System.Console.ReadLine());
            }

            System.Console.Write("\n==============================================");
            System.Console.Write("\nStatement of Accounts");
            System.Console.Write("\n==============================================");
            
            if (customercode == "B")
            {
                System.Console.Write("\nBusiness Customer");

                fee = 15;
                System.Console.WriteLine("\nBill Processing fee: {0:C2}", fee);
                basic = fee + 75;
                temp = basic + fee;
                System.Console.WriteLine("Basic Service Fee: {0:C2}", basic);
                if (connection <= 10)
                {
                    amount = 0;
                }
                else
                {

                    amount = basic + ((connection - 10) * 5);

                }

                premium = (50 * numberchannel);
                basic = temp;
                amount = amount + premium;
            }
            else
            {
                System.Console.Write("\nResidential Customer");
                fee = 4.50;
                System.Console.WriteLine("\nBill Processing fee: {0:C2}", 4.5);
                basic = 20.50;
                System.Console.WriteLine("Basic Service Fee: {0:C2}", basic);
                basic = fee + basic;
                premium = (7.5 * numberchannel);
                amount = basic + premium;
            }
            System.Console.Write("\n==============================================");
            System.Console.WriteLine("\nAccount Number: {0} " ,accountnumber);
            System.Console.WriteLine("Customer Name: {0}", customername);
            System.Console.WriteLine("Premium Channels: {0:C2}" ,(amount - (basic)));
            System.Console.WriteLine("Bill Amount: " + (amount.ToString("F")));

            System.Console.ReadKey();
            System.Console.Clear();


        }
    }
}

So that's it.. I hope it'scorrect. nyahaha 🙂
-Tinay :*

You Might Also Like...

No Comments

    Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.