C# Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NewAcmeStore
{
public class Shop
{
private string name;
private string address;
//Constructor
public Shop(string n, string a)
{
name = n;
address = a;
}
//display method
public void display()
{
Console.WriteLine("\n Shop Name: " + name + "\n Address: " +
address + " \n");
}
}
public class Basket:Shop
{
private int breadCount;
private int milkCount;
private int cheeseCount;
public Basket(string n, string a):base(n, a)
{
}
public int getBreadCount()
{
return breadCount;
}
public void setBreadCount(int r)
{
breadCount = r;
}
public int getMilkCount()
{
return milkCount;
}
public void setMilkCount(int r)
{
milkCount = r;
}
public int getCheeseCount()
{
return cheeseCount;
}
public void setCheeseCount(int r)
{
cheeseCount = r;
}
public void displayBill()
{
double breadCost = getBreadCount() * 12.95;
double milkCost = getMilkCount() * 6.95;
double cheeseCost = getCheeseCount() * 24.95;
double subTotal = breadCost + milkCost + cheeseCost;
double tax = subTotal * 6 / 100;
Console.WriteLine("\n");
Console.WriteLine("\t\t\tACME SUPER STORE");
Console.WriteLine("\t\t ====================\n");
Console.WriteLine("\t\t\tCustomer Receipt\n\n");
Console.WriteLine("\t\tExpensive Bread\t\t{0:C}\n\n",
breadCost);
Console.WriteLine("\t\tExpensive Milk\t\t{0:C}\n\n",
milkCost);
Console.WriteLine("\t\tExpensive Cheese\t{0:C}\n\n",
cheeseCost);
Console.WriteLine("\t\tSubtotal\t\t{0:C}\n", subTotal);
Console.WriteLine("\t\tSales Tax (6%)\t\t{0:C}\n", tax);
Console.WriteLine("\t\tTotal\t\t\t{0:C}\n\n", subTotal +
tax);
}
}
public class TestBasket
{
public static void Main(string[] args)
{
Basket myBasket = new Basket("XTZ Stores", "PQR Street, NY");
/* ------------------------------------------------------ */
List<Basket> baskets = new List<Basket>();
char outerLoop = 'y';
while (outerLoop == 'y')
{
//Variable to hold user input
int ch;
//Looping variable
bool loop = true;
myBasket.display();
try
{
//Loop till user wants to quit
while (loop)
{
//Prompting user for product number
Console.Write("\n Enter product number 1, 2, 3 or -1 to quit:
");
//Reading input from user
ch = Convert.ToInt32(Console.ReadLine());
//If -1 break the loop
if (ch == -1)
loop = false;
//If 1, updates bread count
else if (ch == 1)
myBasket.setBreadCount(myBasket.getBreadCount() + 1);
//If 2, updates milk count
else if (ch == 2)
myBasket.setMilkCount(myBasket.getMilkCount() + 1);
//If 3, updates cheese count
else if (ch == 3)
myBasket.setCheeseCount(myBasket.getCheeseCount() + 1);
//Any other value
else
Console.WriteLine("\n Invalid product number \n");
}
/* ------------------------------------------------------ */
myBasket.displayBill();
//Adding to list
baskets.Add(myBasket);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.Write("\nDo you want to process another basket? (y/n):
");
outerLoop = Console.ReadLine()[0];
}
Console.ReadKey();
}
}
}
_______________________________________________________________________________________________________
Sample Run:
code needed for a final project written in C# language .Net (Console Application). Guideline- 1) Must...