Tuesday 23 April 2013

22nd April 2013 this qt asked by inst(Discount)


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

namespace ConsoleApplication24
{
    class bill
    {
        string itnm;
        int rs, disc, final, num;
        public void get()
        {
            Console.WriteLine("enter the item name:");
            itnm = Convert.ToString(Console.ReadLine().ToLower());
            Console.WriteLine("Enter the price of item:");
            rs = Convert.ToInt32(Console.ReadLine());
        }
        public void select()
        {
            Console.WriteLine("choose 1 for pay by CC or 2 by DC");
            num = Convert.ToInt32(Console.ReadLine());
            switch (num)
            {
                case 1:
                    Console.WriteLine("pay by Credit Card:");
                    break;
                case 2:
                    Console.WriteLine("pay by Debit Card:");
                    break;
                default:
                    Console.WriteLine("Invaid input");
                    break;
            }
        }
        public void discount()
        {
            if (rs > 20000)
            {
                disc = rs * 20 / 100;
                final = rs - disc;
                Console.WriteLine("Price after 20% discount to be paid:" + final);
            }
            else if (rs > 12000 && rs < 20000)
            {
                disc = rs * 10 / 100;
                final = rs - disc;
                Console.WriteLine("Price after 10% discount to be paid:" + final);
            }
            else if(rs < 12000)
            {
                disc=rs*5/100;
                final=rs-disc;
                Console.WriteLine("Price after 5% discount to be paid"+final);
            }
        }
    }


    class Program
    {
        static void Main(string[] args)
        {
            bill b=new bill();
            b.get();
            b.select();
            b.discount();
            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment