Question

code needed for a final project written in C# language .Net (Console Application). Guideline- 1) Must...

code needed for a final project written in C# language .Net (Console Application).

Guideline-
1) Must have at least one class and a child class , not counting a main program class.
2) must contain methods
3) must contain loops
4) must contain an if or a switch statement
5) must have at least one array or list
6) make sure to use TryParse to avoid the program from crashing and error handling where necessary.

( preferred project types include a hotel reservation, a schedule of airplanes, or an auto shop bill that includes oil, tire rotation, state inspection etc. feel free to do any other kind of example)

The project does not have to be overly complicated just something simple that meets the above criteria.

Need this ASAP please! Thank you very much!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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:

Add a comment
Know the answer?
Add Answer to:
code needed for a final project written in C# language .Net (Console Application). Guideline- 1) Must...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT