motherboards
Arctic
Arctic Feezer 7x
Results 1 to 2 of 2

Thread: A question for those familiar with C#

  1. #1
    Regular Member

    Status
    criss_glitch666 is offline

    Last Online
    09-03-2015 @ 23:28
    Join Date
    Dec 2008
    Posts
    1,777
    Thanks
    275
    Thanked 112 Times in 95 Posts
    Points: 13,054, Level: 34
    Points: 13,054, Level: 34
    Level completed: 58%,
    Points required for next Level: 296
    Level completed: 58%, Points required for next Level: 296
    Overall activity: 14.0%
    Overall activity: 14.0%

    Default A question for those familiar with C#

    Hello,

    I am working on an assignment for college and need some help. The assignment is to create a console application for shirts that asks you the color, quantity, if you want shipping, then gives you the total. I'm fine with it all except for..... I have created a switch statement that lists the shirt colors along with their cost. I'm trying to figure out how to have the switch re-run when the user inputs an invalid string.

    Code:
    using System;using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    
    namespace Shirts
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("********SHIRT COLOURS********");
                Console.WriteLine("Shirt colours: Blue, Green, Yellow, Brown, Other");
                Console.Write("Please enter your selection: ");
                string colour = Console.ReadLine();
    
    
                do
                {
                    switch (colour)
                    {
                        case "blue":
                            cost = 20;
                            break;
                        case "green":
                            cost = 20;
                            break;
                        case "yellow":
                            cost = 10;
                            break;
                        case "brown":
                            cost = 5;
                            break;
                        case "other":
                            cost = 15;
                            break;
                        default:
                            Console.Write("You have entered an invalid string.");
                            break;
                    }

  2. #2
    Regular Member

    Status
    Shell_Shock is offline

    Last Online
    05-07-2016 @ 00:39
    Join Date
    Aug 2013
    Location
    Waterford, PA
    Posts
    235
    CPU: Intel G3259 3.2 GHZ LGA 1150
    M/B: MSI Z97 PC Mate
    RAM: Kingston 125GB SSD
    GPU: PNY 465
    • Shell_Shock's Full Spec's
      • Case:
      • ThermalTake Urban T81
      • PSU:
      • EnerMax Revolution Xt 630w
      • Cooling:
      • Dragons blood dye, NZXT 240mm RAD, Danger Den Bay Res, DDC Pump, Primochill Fittings, PETG HArd Line Tubing
      • Monitor:
      • Piece of Crap
      • OS:
      • Windows 8.1
    Thanks
    1
    Thanked 24 Times in 18 Posts
    Points: 3,693, Level: 17
    Points: 3,693, Level: 17
    Level completed: 61%,
    Points required for next Level: 157
    Level completed: 61%, Points required for next Level: 157
    Overall activity: 13.0%
    Overall activity: 13.0%

    Default Re: A question for those familiar with C#

    Im not sure if C# has the same syntax as C++, but would an if then statement work? For instance, if the input by the user is accurate, do this else the intput is wrong, go back to the beginning?
    Programmer, Ethical Hacker, Tech Support, Geek Extraordinaire.

Remove Ads

Sponsored Links

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Similar Threads

  1. Ram Question
    By fscrivy in forum General Hardware
    Replies: 2
    Last Post: 12-09-2013, 11:01
  2. SSD question
    By Carl in forum General Hardware
    Replies: 7
    Last Post: 23-05-2013, 09:54
  3. Got a question
    By Adham in forum Graphics Cards
    Replies: 20
    Last Post: 08-11-2012, 20:31
  4. Gpu Question
    By Nethemis in forum Graphics Cards
    Replies: 3
    Last Post: 28-03-2010, 21:35
  5. new cpu question
    By srice425 in forum CPU Overclocking
    Replies: 4
    Last Post: 26-10-2008, 19:41

Search tags for this page

There are currently no search tags.
Click on a term to search for related topics.

Tags for this Thread