Sunday, October 16, 2016

Product Bill Calculator in C#

Here is a sample program that I wrote in C# that will ask the user to give the product name, product quantity and product price and then our program will compute for the total cost of the product. What is good about this program is that I added a function that will prompt and ask the user do you want to continue using this program or not which enables the user to repeat the program running again and able to provide new values in a the other product. I hope you will find my work useful. Thank you.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.




Sample Program Output

Program Listing

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

// October 16, 2016  Sunday
// Author : Mr. Jake R. Pomperada, MAED-IT
// Program to compute bill given price and quantity

namespace bill_solver
{
    class bill
    {
        static void Main(string[] args)
        {
            string product_name, reply;
            int quantity = 0,n=0;
            double price = 0, amount = 0;
            
        do {
            Console.Clear();
            Console.Write("Product Bill Calculator");
            Console.Write("\n\n");
            Console.Write("Enter Product Name      : ");
            product_name = Console.ReadLine();
            Console.Write("Enter Quantity          : ");
            quantity = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter Product Price Php : ");
            price = Convert.ToDouble(Console.ReadLine());

            amount = (quantity * price);

            Console.Write("\n\n");
            Console.Write("===== DISPLAY RESULTS =====");
            Console.Write("\n\n");
            Console.WriteLine("Product          :  {0}.", product_name);
            Console.WriteLine("Price            :  {0:0.00}.", price);
            Console.WriteLine("Quantity         :  {0}.", quantity);
            Console.Write("\n\n");
            Console.WriteLine("Total Cost       : Php {0:0.00}.", amount);
            Console.Write("\n\n");
            Console.Write("Do You Want To Continue? Y/N : ");
            reply = Console.ReadLine();

            if (reply == "y" || reply == "Y")
            {
                continue;
            }
            else if (reply == "n" || reply == "N")
            {
                Console.Write("\n\n");
                Console.Write("Thank You For Using This Software.");
                Console.Write("\n\n");
                break;
            }
           
        } while (n == 0);
        Console.ReadLine();
        } 
    }
}



No comments:

Post a Comment