0% found this document useful (0 votes)
5 views

Using System

The document contains code for an inventory management system and sales commission calculator. The inventory code defines an InventoryItem class to represent items with properties like code, initial units, purchased units, issued units, and methods to calculate closing units and check if below lower limit. The main method gets input to create InventoryItem objects and displays output. The sales code defines a Salesperson class to represent a salesperson with an array of item sales values and a method to calculate earnings from a 200 base pay and 9% commission on total sales. The main method gets input for item sales values and displays the calculated earnings output.

Uploaded by

Syed Ali Hashmi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Using System

The document contains code for an inventory management system and sales commission calculator. The inventory code defines an InventoryItem class to represent items with properties like code, initial units, purchased units, issued units, and methods to calculate closing units and check if below lower limit. The main method gets input to create InventoryItem objects and displays output. The sales code defines a Salesperson class to represent a salesperson with an array of item sales values and a method to calculate earnings from a 200 base pay and 9% commission on total sales. The main method gets input for item sales values and displays the calculated earnings output.

Uploaded by

Syed Ali Hashmi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

using System;

class InventoryItem
{
public int ItemCode;
public int InitialUnits;
public int PurchasedUnits;
public int IssuedUnits;

public int CalculateClosingUnits()


{
return InitialUnits + PurchasedUnits - IssuedUnits;
}

public bool IsBelowLowerLimit()


{
double lowerLimit = 0.01 * InitialUnits;
int closingUnits = CalculateClosingUnits();
return closingUnits < lowerLimit;
}
}

class InventoryLevelCalculator
{
static void Main()
{
Console.WriteLine("Inventory Level Calculator");
Console.WriteLine("==========================");

while (true)
{
Console.Write("\nEnter item code or -1 to quit: ");
int itemCode = int.Parse(Console.ReadLine());

if (itemCode == -1)
break;

Console.Write("Enter initial number of units: ");


int initialUnits = int.Parse(Console.ReadLine());

Console.Write("Enter number of units purchased: ");


int purchasedUnits = int.Parse(Console.ReadLine());

Console.Write("Enter number of units issued: ");


int issuedUnits = int.Parse(Console.ReadLine());

InventoryItem item = new InventoryItem();


item.ItemCode = itemCode;
item.InitialUnits = initialUnits;
item.PurchasedUnits = purchasedUnits;
item.IssuedUnits = issuedUnits;

int closingUnits = item.CalculateClosingUnits();


Console.WriteLine($"\nClosing number of units for item {item.ItemCode} is {closingUnits}");

if (item.IsBelowLowerLimit())
{
Console.WriteLine("Procure more units immediately");
}
}
}
}

using System;
class Salesperson
{
public double[] ItemsSold;

public double CalculateEarnings()


{
double totalSales = 0;
foreach (double itemValue in ItemsSold)
{
totalSales += itemValue;
}

double commission = 0.09 * totalSales;


double earnings = 200 + commission;

return earnings;
}
}

class SalesCommissionCalculator
{
static void Main()
{
Console.WriteLine("Sales Commission Calculator");
Console.WriteLine("==========================");

Salesperson salesperson = new Salesperson();

Console.Write("Enter the number of items sold: ");


int itemCount = int.Parse(Console.ReadLine());

salesperson.ItemsSold = new double[itemCount];

for (int i = 0; i < itemCount; i++)


{
Console.Write($"Enter the value of item {i + 1}: ");
salesperson.ItemsSold[i] = double.Parse(Console.ReadLine());
}

double earnings = salesperson.CalculateEarnings();

Console.WriteLine($"\nThe salesperson's earnings for this week is: ${earnings}");


}
}

You might also like