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 ITEM_Calculation
{
class ITEM
{
int[] num = new int[5];
string[] PName = new string[5];
double[] unitprice = new
double[5];
int[] quantiy = new int[5];
double[] TPrice = new
double[5];
double discount;
double[] Total = new double[5];
double Sum = 0;
public void GetData()
{
for (int i = 0; i
< 5; i++)
{
num[i] = i + 1;
Console.WriteLine("\nProduct:{0}", num[i]);
Console.WriteLine("Enter product name");
PName[i] = Console.ReadLine();
Console.WriteLine("Enter unit price");
unitprice[i] = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter Quantity");
quantiy[i] = Convert.ToInt32(Console.ReadLine());
TPrice[i] = quantiy[i] * unitprice[i];
Console.WriteLine("Total price of this product={0}",TPrice[i]);
Sum = Sum + TPrice[i];
}
}
public void Display()
{
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}",i+1,PName[i],unitprice[i],quantiy[i],TPrice[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....!!! ");
}
}
class Program
{
static void Main(string[] args)
{
ITEM I1 = new ITEM();
I1.GetData();
I1.Display();
}
}
}
Output:
No comments:
Post a Comment