Objective:
Write a simple program in
which calculate the total amount of items that are sold. Calculate Total Price
after discount.
Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ItemCalc
{
class Program
{
static void Main(string[] args)
{
int[] ItemNUM = new int[5];
string[] ITEMName = new
string[5];
double[] unitprice = new
double[5];
int[] quantiy = new int[5];
double[] price= new double[5];
double discount;
double[] Total = new double[5];
double Sum=0;
for (int i = 0; i
< 5; i++)
{
ItemNUM[i] = i + 1;
Console.WriteLine("IITEM {0}",ItemNUM[i]);
Console.WriteLine("Enter ITEM Name");
ITEMName[i] = Console.ReadLine();
Console.WriteLine("Enter unit price");
unitprice[i] = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter Quantity");
quantiy[i] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
Total[i] = quantiy[i] * unitprice[i];
Console.WriteLine("Total Price of ITEM:{0} ={1}\n",ItemNUM[i],Total[i]);
Sum = Sum + Total[i];
}
Console.WriteLine("ENter
Discount in %");
int disc =Convert.ToInt32(
Console.ReadLine());
Console.WriteLine("\nITEM
\t ITEM Name\t Unit Price \t Quantity\t
Total Price\n");
for(int i=0;
i<5;i++)
{
Console.WriteLine("ITEM:{0} \t{1}\t\t{2}\t\t{3}\t\t{4}",
ItemNUM[i], ITEMName[i], unitprice[i], quantiy[i], Total[i]);
}
Console.WriteLine("\nTotal
Amount={0}",Sum);
discount = Convert.ToDouble((disc /
100.0) * Sum);
double TotalPrice = Sum - discount;
Console.WriteLine("Amount
After discount={0}",TotalPrice);
Console.WriteLine("Please
recieve the amount....!!! ");
}
}
}
Output:
No comments:
Post a Comment