#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    3
    Rep Power
    0

    Mini C# Project Help.


    This is my project to be created:

    Create a program for a small gift shop in Ayloff Community Hospital that will be able to accept the name of an item, the cost and quantity. The program will repeat the previous steps until the customer has finished their purchases. The program must be able to keep a running total. When the customer has finished with their purchases they will receive a 15% discount if they have a club card. If there is another customer the program will be able to repeat the process after it has cleared the screen.

    My code so far:

    {
    class Program
    {
    const double pye = 3.14;
    static void Main(string[] args)
    {//Start of main program


    int choice; //Declaring the variable
    char exitProgram = 'Y';

    Console.WriteLine("Program to calculate the area of shapes");
    Console.WriteLine();
    while (exitProgram == 'Y')
    {
    Console.WriteLine("Please enter 1 to look at our choices of Drinks.");
    Console.WriteLine("Please enter 2 to look at our choices of Food.");
    Console.WriteLine("Please enter 3 to look at our Gifts.");
    Console.WriteLine("Please enter 4 to look at your Total to Pay.");
    choice = int.Parse(Console.ReadLine()); //Parsing the line
    Console.Clear();

    switch (choice) //Switch, this is easier if you have loads of choices
    {
    case 1:
    drinks();
    break;
    default:
    Console.WriteLine("You've entered an incorrect number");
    break;
    }

    Console.Clear();
    Console.WriteLine("If you would like anything else press Y if not then N.");
    exitProgram = char.Parse(Console.ReadLine());


    } //End of loop
    Console.ReadKey();
    }//End of main program

    static void drinks() //Here is the Drinks method
    {


    Console.WriteLine("1...Canned Coca Cola ---> 60P ");
    Console.WriteLine("2...Canned Fanta Orange ---> 60P");
    Console.WriteLine("3...Bottled Coca Cola ---> 85P");
    Console.WriteLine("4...Bottled Fanta Orange ---> 85P");
    Console.WriteLine("5...Bottled Water ---> 70P");

    string choice = Console.ReadLine();
    Console.Clear();

    if (choice == "1")
    Console.WriteLine("That will be 60P Please! ");
    if (choice == "2")
    Console.WriteLine("That will be 60P Please! ");
    if (choice == "3")
    Console.WriteLine("That will be 85P Please! ");
    if (choice == "4")
    Console.WriteLine("That will be 85P Please! ");
    if (choice == "5")
    Console.WriteLine("That will be 70P Please! ");
    Console.ReadKey();
    }
    }//Closes class
    }//Closes namespace

    For some reason my mind has just blocked up and i can't figure out to go from here.. Obviously i can just repeat the same as i did for the Drinks for food and gifts that is pretty easy. But the rest i'm stuck on, ANY HELP would be appreciated.

    I'm not asking anyone to do my project for me essentially just need some help. Thanks once again.

    Comments on this post

    • b49P23TIvg disagrees : Unbelievable. TheAntnog won't read own program.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    10
    Rep Power
    0
    You still need to have a way of incrementing the cost if they choose more than one item.

    Plus a way to back out, to get back to the original selections, drinks, food, ect.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by TheDeadveloper
    You still need to have a way of incrementing the cost if they choose more than one item.

    Plus a way to back out, to get back to the original selections, drinks, food, ect.
    The cost bit is a big issue, i can't get my head around it!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    10
    Rep Power
    0
    Originally Posted by TheAntnog
    The cost bit is a big issue, i can't get my head around it!
    In the method drinks I would add 1 more Console.WriteLine("6...Main Menu --->");


    You should change this to a switch:
    Code:
    if (choice == "1")
    Console.WriteLine("That will be 60P Please! ");
    if (choice == "2")
    Console.WriteLine("That will be 60P Please! ");
    if (choice == "3")
    Console.WriteLine("That will be 85P Please! ");
    if (choice == "4")
    Console.WriteLine("That will be 85P Please! ");
    if (choice == "5")
    Console.WriteLine("That will be 70P Please! ");
    if (choice == "6")
    Console.Clear();
    Console.WriteLine("Please enter 1 to look at our choices of Drinks.");
    Console.WriteLine("Please enter 2 to look at our choices of Food.");
    Console.WriteLine("Please enter 3 to look at our Gifts.");
    Just above the new switch you can declare a variable to hold totCost.

    Then you can increment that var for each choice in the new switch.

    Example for new switch:
    Code:
    switch(choice)
    {
     case 1:
        totCost += 60;
        Console.WriteLine("That will be " + totCost + "P Please! ");
        break;
    case 2:
        totCost += 60;
        Console.WriteLine("That will be " + totCost + "P Please! ");
        break;
    }
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by TheDeadveloper
    In the method drinks I would add 1 more Console.WriteLine("6...Main Menu --->");


    You should change this to a switch:
    Code:
    if (choice == "1")
    Console.WriteLine("That will be 60P Please! ");
    if (choice == "2")
    Console.WriteLine("That will be 60P Please! ");
    if (choice == "3")
    Console.WriteLine("That will be 85P Please! ");
    if (choice == "4")
    Console.WriteLine("That will be 85P Please! ");
    if (choice == "5")
    Console.WriteLine("That will be 70P Please! ");
    if (choice == "6")
    Console.Clear();
    Console.WriteLine("Please enter 1 to look at our choices of Drinks.");
    Console.WriteLine("Please enter 2 to look at our choices of Food.");
    Console.WriteLine("Please enter 3 to look at our Gifts.");
    Just above the new switch you can declare a variable to hold totCost.

    Then you can increment that var for each choice in the new switch.

    Example for new switch:
    Code:
    switch(choice)
    {
     case 1:
        totCost += 60;
        Console.WriteLine("That will be " + totCost + "P Please! ");
        break;
    case 2:
        totCost += 60;
        Console.WriteLine("That will be " + totCost + "P Please! ");
        break;
    }
    You are amazing, that worked out thank you so much! :tntworth:
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    10
    Rep Power
    0
    Thank you, I've been doing C#.NET for 8 yrs.

    Just happen to be in here because my boss needs something in C.

    Glad I could help. :cheers:

IMN logo majestic logo threadwatch logo seochat tools logo