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.
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
@@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.
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.
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
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.
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.
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 🙏
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
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?
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?
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
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?
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!
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
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?
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(); }
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
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
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); }
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); } } } }
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.
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
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
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); } } }
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
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"); }
I'm having the same question ! i thought it was already answered by someone else. if you got it, please make me understand about why "int UserChoice = -1"
!= 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 !==
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); } } }
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.
why int UserChoice = -1 .???
Thank you sir.
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
@@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.
im learning c# very well because of u.............thank u soo much...
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.
Fantastic. My fears of programming all gone watching your videos. Such a great explanation. Brilliant.
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!
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
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.
Easy to understand Indian assent.... :D
Download this video, install the gom player, listen over there with extend volume for more clearly.
I like the way you teach and not hiding your mistakes in these videos.
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.
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.
Very nice videos. easy.. Thank you for posting, appreciated
Thanks Venkat - excellent coverage and beautifully explained.
Man, You rock, You have Exceptonal power to teach.....
it"s almost 11 years still your channel c sharp videos >>>>>>>>>>>>>>>> whole youtube c sharp tutorials
I am in love with this c sharp series ..
That's really excellent Venkat. Thank You !
That's really excellent Venkat sir. Thank You !
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 🙏
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
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?
very informative series
thank you venkat sir.....!
sir thank you for that.......it very helpful for our preparation.....
thank you once again
now is 2019 and i learn with your Tutorial because your teaching method is great.
Very interesting demo sir. Thank you....
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?
Sir, thank you very much. Mean a lot! Your big fan!
Great videos!! Thanks for you hard work. Very well explained.
Sir thank you very much, i am looking forward to all your tutorials.
very good job thnx a lot this is the best tutorial h have seen
Thank you Bro for videos, they are really useful
Thank you for your time and knowledge kudvenkat.
IT IS 1 OF THE BEST TUTORIAL. BUT SOUND QUALITY IS LITTLE POOR.BUT YOU ARE A GREAT TEACHER.
haha them brain farts but thanks really enjoying your vids
thank you sir your videos are helpful.
such an amazing teacher u r..:)
Excellent!
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
Yes, it's easier but Kudvenkat said that it's not recommended to use goto statement :)
Awesome is the word that i find for you brother....At last m learning C# n .net....YAY!!!!!!
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?
where do you study?
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.
I like this series very much.
Would be nice if the code for the last example was available to download in .txt format.
sir why u used -1 in coffee program in the first using dowhile
Thank you for your videos, they are great! I am planning to watch ALL! :-) Any videos in debugging in the future maybe?
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?
So Helpful!!!
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!
You are great
Kudvenkat...did you address how to handle if the user inputs string garbage for UserChoice? Did I miss it? Thank you.
Sir, can you tell me which is next logic step in learning. ASP.NET or ADO.NET.
thank you for your help
do while means the code runs once without checking the condition, and check the condition from the second time and up
just change the speed to 1.4 , still understandable and saves ur time
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
Thank you
Sir, If I Use Goto Statement, then which one is right approach?
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?
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?
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?
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();
}
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
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
Is there a way you can write switch statements without "goto" by using a do loop?
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
hi thanks for the video..will you please explain the term int userchoice = -1; why we are using it in coffee program
It doesn't matter, you can just initialize the variable. It works fine for me .
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);
}
Damn man your a genius. Very good explanation. If you are here I'm gonna kiss you on your lips lol.
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);
}
}
}
}
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.
Please try Console.Writeline() instead of Console.Write(). Hope this helps.
Hi Jerry, I would say ADO.NET.
good tutorials. can we have for c++?
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
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
tryparse is what ur looking for, store the result of tryparse in a bool then use this bool in the do while
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.
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);
}
}
}
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
Instead of yes or no why condition is yes and no? Please can you explain?
Can you provide me that Do while coffee example code.
Plase share slide of your code for practise.....
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");
}
in console application biggest no programing i put 1 no and enter than another no didnt put
Can you explain sir why "int UserChoice = -1" here.
I'm having the same question !
i thought it was already answered by someone else.
if you got it, please make me understand about why "int UserChoice = -1"
why int UserChoice = -1 .???
❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
Kind Suggestion plz don't make video's of more than 12 min,ppl like me keep checking when it's gonna end
Why did he initialise userschoice as -1
Is != and !== different? Can any one clear my doubt?
!= 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 !==
10:40 Unexpected situation
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");
}
}
You are one of my favorite teacher. thanking u for giving me valuable knowledge of c#
okey
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);
}
}
}
thank you
Why int UserChoice = -1 ?