Part 14 - C# Tutorial - do while loop in c#

Поделиться
HTML-код
  • Опубликовано: 29 окт 2024

Комментарии • 108

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  11 лет назад +15

    Thank you very much for taking time to give feedback. In the description of this video, I have included the link for ASP .NET, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists, which could be useful to you. Please share the link with your friends who you think would also benefit from them. If you like these videos, please click on the THUMBS UP button below the video. For email alerts, when new videos are uploaded, you may subscribe to my channel.

    • @masoomsh4112
      @masoomsh4112 5 лет назад

      why int UserChoice = -1 .???

    • @nehagulati1771
      @nehagulati1771 5 лет назад

      Thank you sir.

    • @varunikareddy1130
      @varunikareddy1130 4 года назад

      I was executed this programme, but i get the outpot like this
      Enter your target
      5
      0 2 4 do you want to continue -yes or no
      Yes
      Press any key to continue---
      Why i didn't go to back stmt(do you want to execute or not) pls help me,i checked many times pls help me

    • @SAHINgaming18
      @SAHINgaming18 4 года назад

      @@varunikareddy1130 after the while loop you must put the next while while(userchoice==yes) then u will get the output. But remember to write the do while before the printing statement of target?.. or otherwise u just see the program and write the same as in the video u will get the output and three times u ll see the program u will understand.

  • @kchaitanya2148
    @kchaitanya2148 9 лет назад +17

    im learning c# very well because of u.............thank u soo much...

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  12 лет назад +6

    Thank you very much for letting me know about this issue. The new videos, should not have this problem any more. I will try to re-record as soon as I can. I think it was an issue with the mic I used for recording.

  • @naimislam1019
    @naimislam1019 9 лет назад +12

    Fantastic. My fears of programming all gone watching your videos. Such a great explanation. Brilliant.

  • @hageadan
    @hageadan 8 лет назад +13

    Thank you for sharing these videos with us. You are greatly appreciated by all who encounter your channel and want to learn .NET and C#
    God bless you!

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  8 лет назад +8

      You are very welcome and thank you very much for taking time to give feedback. This means a lot. I am very glad you found the videos useful.
      I have organised all the Dot Net & SQL Server videos in to playlists, which could be useful to you
      ruclips.net/user/kudvenkatplaylists?view=1&sort=dd
      If you need DVDs or to download all the videos for offline viewing please visit
      www.pragimtech.com/kudvenkat_dvd.aspx
      Slides and Text Version of the videos can be found on my blog
      csharp-video-tutorials.blogspot.com
      Tips to effectively use my youtube channel.
      ruclips.net/video/y780MwhY70s/видео.html
      If you want to receive email alerts, when new videos are uploaded, please subscribe to my youtube channel.
      ruclips.net/user/kudvenkat
      If you like these videos, please click on the THUMBS UP button below the video.
      May I ask you for a favor. I want these tutorials to be helpful for as many people as possible. Please share the link with your friends and family who you think would also benefit from them.
      Good Luck
      Venkat

  • @larabsteve3350
    @larabsteve3350 8 лет назад +1

    There are few inspiring people in the world after my parents your are the one that inspired me to something great thank you very much for your wonderful videos. I will never get bore listening you.You are amazing teacher.

  • @ckbapps2009
    @ckbapps2009 9 лет назад +10

    Easy to understand Indian assent.... :D
    Download this video, install the gom player, listen over there with extend volume for more clearly.

  • @mahrabhossain5675
    @mahrabhossain5675 4 года назад +1

    I like the way you teach and not hiding your mistakes in these videos.

  • @mazdyabosoraya
    @mazdyabosoraya 12 лет назад +2

    Sir, you rock..i read like 10 books and million tutorials..and they still do not explain like you! Thank you very much. Please when you have time, record some videos for events and events handler because this concept I find is very confusing.

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  12 лет назад +2

    Hi, I will try to update the post, with sample code as soon as I can, so you can download it. Thank you very much for the feedback.

  • @ravikanthputta
    @ravikanthputta 9 лет назад +4

    Very nice videos. easy.. Thank you for posting, appreciated

  • @noelmcwilliam9182
    @noelmcwilliam9182 10 лет назад +2

    Thanks Venkat - excellent coverage and beautifully explained.

  • @nurshah816
    @nurshah816 11 лет назад +1

    Man, You rock, You have Exceptonal power to teach.....

  • @vineethrathna
    @vineethrathna 10 месяцев назад +2

    it"s almost 11 years still your channel c sharp videos >>>>>>>>>>>>>>>> whole youtube c sharp tutorials

  • @yuwendridesilva6956
    @yuwendridesilva6956 3 года назад +1

    I am in love with this c sharp series ..

  • @BogdanMoisin
    @BogdanMoisin 11 лет назад +3

    That's really excellent Venkat. Thank You !

  • @shaileshprasad2330
    @shaileshprasad2330 3 года назад

    That's really excellent Venkat sir. Thank You !

  • @Dotto19
    @Dotto19 5 лет назад +1

    Thank you Venkat.
    I have learned so much from watching your videos.
    Can you make a video on string APIs please.
    It would be greatly appreciated.
    Thanks 🙏

  • @secretlives2734
    @secretlives2734 8 лет назад +1

    thank you sir ...u made csharp so much interesting....ur a great teacher bt I wonder who would b your teacher who molded u to sch a great programmer....god bless u with loads of happiness

  • @confidential303
    @confidential303 6 лет назад +3

    It may be me, but I find the GOTO statement more cleaner then nested do-while loop. In a more complex program if you have dozens of do whiles, I feel like getting lost in t he nested loops. But then again I heard so many times to avoid the GOTO :(. But, I will try to follow it. Btw, I have another option in presenting the Yes or NO... I want for lazy people's who really need coffee to also type in Y in stead of YES. so in the Do While loop the condition has to be something like
    while( (Userchoice !==YES || Y) && (Userchoice!==No || N) ) is this the way to go?

  • @assamjaved1444
    @assamjaved1444 3 года назад +1

    very informative series

  • @hariprasad361
    @hariprasad361 2 года назад +1

    thank you venkat sir.....!

  • @MsAbhinavrai
    @MsAbhinavrai 11 лет назад +2

    sir thank you for that.......it very helpful for our preparation.....
    thank you once again

  • @faraidoonnaghdali4837
    @faraidoonnaghdali4837 5 лет назад

    now is 2019 and i learn with your Tutorial because your teaching method is great.

  • @srinivasaraoyp3640
    @srinivasaraoyp3640 5 лет назад +1

    Very interesting demo sir. Thank you....

  • @indianproman
    @indianproman 6 лет назад +2

    i have a small dought
    as you mention in
    if (userchoice != "YES " && userchoice !="NO")
    in this statement, if you give NO then is a program going to move forward? like if you mention && the program will going to check only first condition but not next.
    as & mentioning will go?

  • @mazdyabosoraya
    @mazdyabosoraya 12 лет назад +1

    Sir, thank you very much. Mean a lot! Your big fan!

  • @waheedhai1
    @waheedhai1 12 лет назад +1

    Great videos!! Thanks for you hard work. Very well explained.

  • @mazdyabosoraya
    @mazdyabosoraya 12 лет назад +1

    Sir thank you very much, i am looking forward to all your tutorials.

  • @alaamousa2052
    @alaamousa2052 11 лет назад +2

    very good job thnx a lot this is the best tutorial h have seen

  • @hatsavod2238
    @hatsavod2238 7 лет назад +1

    Thank you Bro for videos, they are really useful

  • @pojer93
    @pojer93 7 лет назад

    Thank you for your time and knowledge kudvenkat.

  • @Idhikapabi
    @Idhikapabi 10 лет назад +9

    IT IS 1 OF THE BEST TUTORIAL. BUT SOUND QUALITY IS LITTLE POOR.BUT YOU ARE A GREAT TEACHER.

  • @siferuk
    @siferuk 10 лет назад +5

    haha them brain farts but thanks really enjoying your vids

  • @lalithtondon1789
    @lalithtondon1789 11 лет назад +2

    thank you sir your videos are helpful.

  • @roshitaraveendran1631
    @roshitaraveendran1631 9 лет назад +1

    such an amazing teacher u r..:)

  • @ModelosPR
    @ModelosPR 12 лет назад +2

    Excellent!

  • @AlexMartinez-be2rh
    @AlexMartinez-be2rh 8 лет назад +1

    Sometimes the goto statement make it simpler than a lot of do while nested more in a big program, in this case I prefer to use the goto statement:
    start:
    Console.WriteLine("Enter a target: ");
    int target = 0;
    int.TryParse(Console.ReadLine(), out target);
    int start = 0;
    do
    {
    Console.WriteLine(start);
    start += 1;
    } while (start

    • @lav4eee
      @lav4eee 4 года назад

      Yes, it's easier but Kudvenkat said that it's not recommended to use goto statement :)

  • @subhadeepdebnath3443
    @subhadeepdebnath3443 8 лет назад

    Awesome is the word that i find for you brother....At last m learning C# n .net....YAY!!!!!!

  • @nihatallahverdiyev81
    @nihatallahverdiyev81 8 лет назад +1

    First of all, I would say that you r really remarkable teacher,I use your videos to improve myself after University lessons,and I have question, why u always use Parse instead of converting toint32 and what is the basic various converting to parse and toint 32?

  • @bartzabielski6422
    @bartzabielski6422 7 лет назад +1

    Where can i view the Do While coffee code? Its hard to follow when paused. I would like to download it and compare it in visual studio.

  • @ModelosPR
    @ModelosPR 12 лет назад +1

    I like this series very much.
    Would be nice if the code for the last example was available to download in .txt format.

  • @mohammedaathir4718
    @mohammedaathir4718 6 лет назад +2

    sir why u used -1 in coffee program in the first using dowhile

  • @TheDoktorot
    @TheDoktorot 11 лет назад

    Thank you for your videos, they are great! I am planning to watch ALL! :-) Any videos in debugging in the future maybe?

  • @sbmahapatra
    @sbmahapatra 3 года назад +1

    Guys, any idea where is the Text version of it? I clicked on the above (Text ersion of the video). But I did not see the text. Any idea?

  • @micahshanetaylor5562
    @micahshanetaylor5562 9 лет назад

    So Helpful!!!

  • @jannisk.5402
    @jannisk.5402 7 лет назад

    First of all, thank you very much for this great tutorial series! The videos are greatly structured and really easy to follow though I hope the audio will somewhat improve in future videos!
    I have some questions regarding the do while loop for the coffee program:
    1.
    Whenever I enter symbols other than numbers I receive a FormatException Error pointing at int.Parse(Console.ReadLine());
    I'm usung Visual Studio 2015 - did windows change anything there or am I missing something else?
    2.
    The question has been raised a couple of times already but I didn't find any explanation for it yet:
    Why is int UserChoice = -1;
    Thanks in advance for your help!

  • @karimmohamed8001
    @karimmohamed8001 6 лет назад

    You are great

  • @lamar2009lamar
    @lamar2009lamar 5 лет назад

    Kudvenkat...did you address how to handle if the user inputs string garbage for UserChoice? Did I miss it? Thank you.

  • @mazdyabosoraya
    @mazdyabosoraya 12 лет назад +1

    Sir, can you tell me which is next logic step in learning. ASP.NET or ADO.NET.

  • @blaiseblanton6518
    @blaiseblanton6518 9 лет назад

    thank you for your help

  • @RobertoLion
    @RobertoLion 6 лет назад

    do while means the code runs once without checking the condition, and check the condition from the second time and up

  • @sahilkarn5912
    @sahilkarn5912 4 года назад

    just change the speed to 1.4 , still understandable and saves ur time

  • @Lord_Shri
    @Lord_Shri 2 года назад

    Hii
    You should have use
    if( userchoice ! = "YES" || userchoice ! = "NO" ) instead if using '&&' because the use is going to only one Statment i.e. "YES" or "NO" and also this case repeat in while loop to

  • @rameshrajendiran1982
    @rameshrajendiran1982 3 года назад

    Thank you

  • @Sraban75
    @Sraban75 6 лет назад

    Sir, If I Use Goto Statement, then which one is right approach?

  • @jangear
    @jangear 11 лет назад +1

    Say you was to add "start =+ 2" instead of "start = start + 2", why would that be different and the out put different?
    are they not both incremented by 2?

  • @charlieconrad3335
    @charlieconrad3335 11 лет назад

    In the coffee shop example, I don't understand why you set userchoice = -1 at the beginning. Shouldn't it be set as an empty variable of int type?

  • @arunsourichitturi5860
    @arunsourichitturi5860 10 лет назад +2

    If user enters string or some garbage value instead of numbers, how to restrict user to enter only numbers? how to put if condition for that?

    • @EnterARandomNameHere
      @EnterARandomNameHere 10 лет назад +1

      I know I'm replying to an old comment, but you could do something like this:
      // put this at the beginning:
      using System;
      using System.Text.RegularExpressions;
      // put this where you want a number-only input:
      string userInput = Console.ReadLine();
      // regex is used to identify inputs with only numbers 0-9
      Regex numConfirm = new Regex(@"\d+");
      while (numConfirm.IsMatch(userInput) == false)
      {
      Console.Clear();
      Console.WriteLine(error_message);
      userInput = Console.ReadLine();
      }

    • @seesharp4690
      @seesharp4690 9 лет назад

      Shiranui if you input a garbage like --- > 1qwe or qwe1 .
      while( true == false) //why true because the r.ismatch(userinput) produce a true ..
      because the regex accepts even if the user input a number + string .sorry bad english.. hahaha

    • @seesharp4690
      @seesharp4690 9 лет назад

      Shiranui if you input a garbage like --- > 1qwe or qwe1 .
      while( true == false) //why true because the r.ismatch(userinput) produce a true ..
      because the regex accepts even if the user input a number + string .sorry bad english.. hahaha

  • @BeLightBeLove
    @BeLightBeLove 9 лет назад

    Is there a way you can write switch statements without "goto" by using a do loop?

  • @0uckU
    @0uckU 12 лет назад

    good helpfull tutorial sir , but slight problem with the voice recording , it pitches low then high , cant able to hear and unable to understand it

  • @chiranjeevmalik2755
    @chiranjeevmalik2755 7 лет назад

    hi thanks for the video..will you please explain the term int userchoice = -1; why we are using it in coffee program

    • @vikaschalla4370
      @vikaschalla4370 6 лет назад

      It doesn't matter, you can just initialize the variable. It works fine for me .

  • @gerardomartinez8640
    @gerardomartinez8640 8 лет назад

    thanks what you teach I make it like this:
    public void Do_While_loop ()
    {
    //do while make at leat the first time what you ask to the program
    bool option = false;
    int num = 0;
    do {
    //this will add 1 every time you repeat the action
    num = num + 1;
    Console.WriteLine (num);
    //conditional for keep going or quit
    Console.WriteLine ("again? press: yes or press any key for quit");
    string answer = Console.ReadLine ().ToUpper ();
    option = answer == "YES" ? true : false;
    } while (option == true);
    }

  • @varusgamer2583
    @varusgamer2583 7 лет назад

    Damn man your a genius. Very good explanation. If you are here I'm gonna kiss you on your lips lol.

  • @manishkishore4912
    @manishkishore4912 7 лет назад

    When I run this on the first attempt it works fine, but when I input some garbage it's started giving me errors after giving correct input on "Do you want to buy Another coffee Yes Or No". When I press yes, it asks me for input again
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading;
    namespace Practicing
    {
    class Program
    {
    static void Main(string[] args)
    {
    try
    {
    int TotalCoffieCost = 0;
    string UserDecision = string.Empty;
    do
    {
    int UserChoice = -1;
    do
    {
    Console.ForegroundColor = ConsoleColor.White;
    Console.WriteLine("Please Enter Your Choice: 1-Small,2-Medium,3-Large");
    UserChoice = int.Parse(Console.ReadLine());
    switch (UserChoice)
    {
    case 1:
    TotalCoffieCost += 50;
    break;
    case 2:
    TotalCoffieCost += 70;
    break;
    case 3:
    TotalCoffieCost += 100;
    break;
    default:
    Console.WriteLine("Your choise {0} Is Invalid", UserChoice);
    break;
    }
    } while (UserChoice != 1 && UserChoice != 2 && UserChoice != 3);
    do
    {
    Console.WriteLine("Do You want to buy another coffie Yes or No");
    UserDecision = Console.ReadLine().ToUpper();
    if (UserDecision != "YES" && UserDecision != "NO") ;
    {
    Console.ForegroundColor = ConsoleColor.Red;
    Console.WriteLine("Your Choise {0} is invalid ", UserDecision);
    Console.ForegroundColor = ConsoleColor.White;
    }
    }
    while (UserDecision != "YES" && UserDecision != "NO");
    }
    while (UserDecision.ToUpper() != "NO");
    Console.WriteLine("ThankYou For shopping With Us
    Your Bill Is Genrating Please Wait");
    Thread.Sleep(3000);
    Console.ForegroundColor = ConsoleColor.Magenta;
    Console.WriteLine("Your bill {0}", TotalCoffieCost);
    }
    catch (Exception e)
    {
    Console.ForegroundColor = ConsoleColor.Red;
    Console.WriteLine(e.Message);
    }
    }
    }
    }

  • @ricksnyder7025
    @ricksnyder7025 6 лет назад

    I am new to C# and I am having trouble with the display portion. The problem asks me to show the purchase price and the discount price if any. I got the right numbers at one time but they both printed on the same line i.e. 50 45 not
    50 purchase price
    45 discounted price. (10% discount)
    Any ideas?
    I have to use a DO WHILE loop.

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  12 лет назад +1

    Hi Jerry, I would say ADO.NET.

  • @mopaomopao
    @mopaomopao 12 лет назад

    good tutorials. can we have for c++?

  • @ypwygk652
    @ypwygk652 4 года назад

    I think you have a mistake in coffee program using do while, that when u enter invalid choice number like 5 you will get infinite loop ..so how to fix this problem

  • @skyz3ra
    @skyz3ra 9 лет назад

    yeah well, if you write letter in first question, it bugs cuz it expect an integer..
    is there any way to say " if UserTarget is not an integer - do this ?"
    like if (usertarget != int)
    {
    Console.WriteLine("Invalid target");
    }
    but it doesnt work like that

    • @Moltenlava
      @Moltenlava 3 года назад

      tryparse is what ur looking for, store the result of tryparse in a bool then use this bool in the do while

  • @abdullahmohibahmed0673
    @abdullahmohibahmed0673 3 года назад

    if we add even yes or no as well it should be recommend as garbage in do loop and it will work in if condition.

  • @shabbirhussain-ph4ib
    @shabbirhussain-ph4ib 6 лет назад

    Code of Do while loop Coffe :
    using System;
    namespace dowhile
    {
    class Program
    {
    static void Main(string[] args)
    {
    int userchoice = -1;
    int totalbill = 0 ;
    string userdec = string.Empty;
    do
    {
    do
    {
    Console.WriteLine("Enter your choice 1-Cofee 2-Chai 3-softdrink");
    userchoice = int.Parse(Console.ReadLine());
    switch (userchoice)
    {
    case 1:
    totalbill += 1;
    Console.WriteLine("Thankyou Your Bill is {0}", totalbill);
    break;
    case 2:
    totalbill += 2;
    Console.WriteLine("Thankyou Your Bill is {0}", totalbill);
    break;
    case 3:
    totalbill += 3;
    Console.WriteLine("Thankyou Your Bill is {0}", totalbill);
    break;
    default:
    Console.WriteLine("Invalid Choice");
    break;
    }
    } while (userchoice != 1 && userchoice != 2 && userchoice != 3);
    do
    {
    Console.WriteLine("Do you want to continue and buy again");
    userdec = Console.ReadLine().ToLower();
    if (userdec != "yes" && userdec != "no")
    {
    Console.WriteLine("Invalid key Try again");
    }
    } while (userdec.ToLower() != "yes" && userdec.ToLower() != "no");
    } while (userdec.ToLower() == "yes");
    Console.WriteLine("Thankyou your total bill is {0}", totalbill);
    }
    }
    }

    • @garaddhanshri8655
      @garaddhanshri8655 2 года назад

      Sir ke program me jab sir first do while likhate hai to while me same condition diya hai ...o samaj me nhi aa raha..... condition is
      If (UserChoice !="yes" && UserChoice !="No");
      Or while me bhi same condition diya hai..... please explain me

  • @KMILIND
    @KMILIND 6 лет назад

    Instead of yes or no why condition is yes and no? Please can you explain?

  • @chandrakishorebakshi6404
    @chandrakishorebakshi6404 9 лет назад

    Can you provide me that Do while coffee example code.

  • @assamjaved1444
    @assamjaved1444 3 года назад

    Plase share slide of your code for practise.....

  • @رفلعقيلعلي
    @رفلعقيلعلي 4 года назад

    I normally do this :
    Use Char instead of the whole word and put it to lower case so it will take the first letter of "yes " and "no"
    char userChoice = Console.ReadLine().ToLower();
    if(userChoice !== 'y' && userChoice != 'n' )
    {
    Console.WriteLine("Invalid choice! Please say yes or no");
    }

  • @vinothv8583
    @vinothv8583 6 лет назад

    in console application biggest no programing i put 1 no and enter than another no didnt put

  • @s.m.giyasuddin4933
    @s.m.giyasuddin4933 7 лет назад

    Can you explain sir why "int UserChoice = -1" here.

  • @masoomsh4112
    @masoomsh4112 5 лет назад +1

    why int UserChoice = -1 .???

  • @shashank_kishore_
    @shashank_kishore_ 10 месяцев назад

    ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤

  • @rajatjain7365
    @rajatjain7365 6 лет назад

    Kind Suggestion plz don't make video's of more than 12 min,ppl like me keep checking when it's gonna end

  • @johnysins7152
    @johnysins7152 3 года назад

    Why did he initialise userschoice as -1

  • @galfrasian
    @galfrasian 3 года назад

    Is != and !== different? Can any one clear my doubt?

    • @Moltenlava
      @Moltenlava 3 года назад

      != is a comparison operator, if variable does not equal to condition then do this thing
      I dont know what !== but when i try to use it it gives me a syntax error so there is most likely nothing as !==

  • @John_Ha
    @John_Ha 3 года назад

    10:40 Unexpected situation

  • @Bhusare001
    @Bhusare001 6 лет назад +1

    using System;
    class Program
    {
    static void Main()
    {
    Int32 totalcoffecost = 0;
    int userchoice = 0;
    string userdesicion = "";
    do
    {
    do
    {
    Console.WriteLine("Please Choose Coffe size: 1 - small, 2 - medium, 3 - large");
    userchoice = Int32.Parse(Console.ReadLine());
    switch (userchoice)
    {
    case 1:
    totalcoffecost += 1;
    break;
    case 2:
    totalcoffecost += 2;
    break;
    case 3:
    totalcoffecost += 3;
    break;
    default:
    Console.WriteLine("Please Choose Valid Size");
    break;
    }
    } while (userchoice != 1 && userchoice != 2 && userchoice != 3);
    do
    {
    Console.WriteLine("Do You Want To Contionue shoping..");
    Console.WriteLine("Please Choose \"Y\" for Yes \"N\" for No");
    userdesicion = Console.ReadLine().ToUpper();
    if (userdesicion != "Y" && userdesicion != "N")
    {
    Console.WriteLine("Please Choose Valid Input");
    }
    } while (userdesicion != "Y" && userdesicion != "N");
    } while ( userdesicion == "Y");
    Console.WriteLine("Your Billing Amount is {0}", totalcoffecost);
    Console.WriteLine("Thanking For Purchasing With Us");
    }
    }

    • @Bhusare001
      @Bhusare001 6 лет назад +1

      You are one of my favorite teacher. thanking u for giving me valuable knowledge of c#

  • @dr.bimbambula
    @dr.bimbambula 6 лет назад

    okey

  • @shreyanshsingh2782
    @shreyanshsingh2782 3 года назад

    using System;
    namespace IntroductionToCsharp
    {
    class Program
    {
    static void Main(string[] args)
    {
    int TotalCostCoffee = 0;
    string UserWantsAgain ="";
    int userchoice = -1;
    do
    {

    do
    {
    Console.WriteLine("Please Select Your Coffee Size:1-Small 2-Medium 3-Large
    ");
    userchoice = int.Parse(Console.ReadLine());
    switch (userchoice)
    {
    case 1:
    TotalCostCoffee += 1;
    break;
    case 2:
    TotalCostCoffee += 2;
    break;
    case 3:
    TotalCostCoffee += 3;
    break;
    default:
    Console.WriteLine("Invalid Choice Choose Again");

    break;
    }
    }
    while (userchoice != 1 && userchoice != 2 && userchoice != 3);
    Console.WriteLine("Do you want to Buy Coffee Again ? Please Answer Yes or No");
    UserWantsAgain = Console.ReadLine().ToUpper();
    }
    while (UserWantsAgain == "YES");
    Console.WriteLine("Thanks For Shopping with us the total cost of coffee is {0}",TotalCostCoffee);
    }
    }
    }

  • @shubhamveer6346
    @shubhamveer6346 4 года назад

    thank you

  • @blinkofficial986
    @blinkofficial986 Год назад

    Why int UserChoice = -1 ?