Saturday, March 15, 2014

MultipleCondition_Ex_1: (Wk-4), Jan 27-31, 2014

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

namespace MultipleCondition_Ex_1
{
    class Program
    {
        static void Main(string[] args)
        {
            //A store sell an item at $33.99
            //If the quantity is more than 10, you'll get a 10 percent discount
            //If the quantity is more than 30, you'll get a 20 percent discount
            //Anything above 50, you'll get 30 percent discount
            //Request the quantity pruchased and compute the subtotal, tax and total
            //Formula: if the percent was 40%, then you compute percentCost = 1-0.4
            //(Which is 0.6 or 60%)


            Console.Write("Enter the quantity of purchased item: ");
            uint q = uint.Parse(Console.ReadLine());

            double percentCost;
            if (q <= 10)
            {
                percentCost = 1; // pay 100%
            }
            else if (q > 10 && q <= 30)
            {
                percentCost = 1 - 0.1; // pay 90%
            }
            else if (q > 30 && q <= 50 )
            {
                percentCost = 1 - 0.2; // pay 80%
            }
            else
            {
                percentCost = 1 - 0.3; // pay 70%
            }
            double subTotal = q * 33.99 * percentCost;
            double tax = subTotal * 0.098;
            double total = subTotal + tax;
            Console.WriteLine("\nSubtotal: {0:c} \nSale Tax: {1:c}", subTotal, tax);
            Console.WriteLine("Total Cost: {0:c}", total);
            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment