Inspiration

Help a restaurant with their POS system

What it does

gets alcohol total & food totals and adds tip tax and returns change

How I built it

built on C#

Challenges I ran into

error checking

Accomplishments that I'm proud of

reusing a method multiple times

What I learned

how to do an error checking loop

What's next for Restaurant POS system

adding a menu database that automatically totals & separates alcohol and food amounts

using System;

namespace ResturantPOS_System { class Program { static void Main(string[] args) { ResturantPOS(); } static void ResturantPOS() { const double tip = 0.18; const double tax = 0.09;

        double foodTotal;
        double alcoholTotal;
        double tipAmount;
        double taxAmount;
        double subTotal;
        double billTotal;
        double customerPayment;
        double changeAmount;

        Console.WriteLine("Resturant POS");

        foodTotal = GetTotals("Food");
        alcoholTotal = GetTotals("Alcohol");
        subTotal = Math.Round((foodTotal + alcoholTotal), 2);
        taxAmount = Math.Round(ExtraCost(subTotal, tax), 2);
        tipAmount = Math.Round(ExtraCost(foodTotal, tip), 2);

        billTotal = subTotal + tipAmount + taxAmount;
        billTotal = Math.Round(billTotal, 2);
        Console.WriteLine($"Food total: ${foodTotal}\n" +
                          $"Alcohol total: ${alcoholTotal}\n" +
                          $"Sub-Total: ${subTotal}\n" +
                          $"Tip amount: ${tipAmount}\n" +
                          $"Tax amount: ${taxAmount}\n" +
                          $"The final bill is: ${billTotal}");
        customerPayment = GetTotals("amount paid");

        changeAmount = customerPayment - billTotal;

        while (changeAmount < 0)
        {
            Console.WriteLine("Insufficent Funds! Please enter the amount of extra cash provided by the customer:");
            changeAmount += double.Parse(Console.ReadLine());

        }
        changeAmount = Math.Round(changeAmount, 2);
        Console.WriteLine($"Change due: ${changeAmount}");

    }

    static double GetTotals(string customText)
    {
        Console.WriteLine($"Please enter {customText}");
        double total = double.Parse(Console.ReadLine());
        while (total < 0)
        {
            Console.WriteLine($"Error! Please enter an amount greater than 0");
            total = double.Parse(Console.ReadLine());
        }
        return total;
    }

    static double ExtraCost(double amount, double rate)
    {
        return amount * rate;
    }
}

}

Built With

Share this project:

Updates