Conditionals and Loops + Calculator Program
Vložit
- čas přidán 1. 07. 2024
- In this video, we discuss conditionals and loops in Java. We cover if-else statements, adding multiple checks, for, while, do-while loops.
In addition to this, we also cover some questions to apply things into practice, and also create a calculator program.
Take part in the learning in public initiative! Share your learnings on LinkedIn and Twitter with #DSAwithKunal & don't forget to tag us!
👉 Resources
- Join Replit: join.replit.com/kunal-kushwaha
- Complete Java DSA playlist: • Java + DSA + Interview...
- Code, Assignments, & Notes: github.com/kunal-kushwaha/DSA...
➡️ Connect with me: www.techwithkunal.com
=========================================
Timestamps:
0:00 Introduction
0:43 Creating New Project
1:28 Conditions
2:15 Syntax of if-else statements
2:54 E1 : if-else statements
4:56 Multiple if-else statements
7:20 Loops
8:46 Syntax of a "for loop"
9:28 E2 : for loop
12:40 E3 : for loop
14:23 Syntax of a "while loop"
14:48 E4 : while loop
17:00 When to use "for loop" and "while loop"
17:57 Syntax of a "do while loop"
18:22 E5 : do while loop
18:57 "while loop" vs "do while loop"
20:44 Solving Questions
20:51 Q1 : Largest number
28:12 Q2 : Alphabet case check
35:03 Q3 : Fibonacci numbers
43:00 Q4 : Counting occurrences
49:14 Q5 : Reverse
53:07 Calculator program
1:01:54 Outro
#loops #placement #dsa #interviews
This Java DSA Series is so Addictive 😍
Thank You!
@@KunalKushwaha this frequency of posting tutorials every alternate day is much better than posting every day as it gives us time to practice properly instead of rushing to keep up with you
@@davs2002 He already mentioned that he'll upload all videos and it will be self paced. Most of us here are in final year and want to brush up all concepts clear before the placements starts so it'll be better if he uploads 1 video everyday.
Also you can watch videos alternate days and practice in between 😀
@@davs2002 bhai terko alternative day mei dekhni hai tho dekh sakta hai...par humare pass jada time nehi hai
@@uncalledbrake603 I am still in 2nd Sem 😀
Who the heck dislikes this😑. Thanks a lot for the efforts Kunal! Really appreciate it. The series has made me switch from Netflix to studying DSA 😂it's so addictive
cfc members 😂
@@aryansharma4775 Damn!😂🙏
Paid classes teachers was disliked this videos 😂😂😂
This is actually THE MOST premium course in the World!
This course is very structured. Many tutorials explain concepts but ignore problem solving . Thank you kunal for this course
I think now everyone can see the Beauty of Java.
Solving any problem flawlessly and with so ease. Wow! Your my new teacher. thanks for your simple and detailed teaching.
I haven't seen.. Anyone teach better..than u Really.. Awsm..
Really appreciate your effort 6 videos in 6 days really excited to learn from you.
kunal, you have no idea how much this course is boosting my confidence....i wish one day i could meet you and thank you personally....
My god I'm amazed by the way u give us the way to build logic for problem-solving, thanks Kunal, never seen such an amazing playlist ever before, thanks, man!
You are the best Programmer explaining DSA such a unique way in Java. I absolutely loved it!!!
I literally just started this series and Oh my God this is pure gold!!,...thank you so much for simplifying everything for us
Hey Kunal! Don't feel pressurized coz of the comments asking for more videos. The frequency and quality of your video is awesome! Cheers and take ur time! Thanks a lot for this commitment ;))
this comment should get a 💖
Bhaiya isme java language basics se padhai hai kya kyuki Mai beginner hu please reply
@@Siddharth3029 yes
Kunal Sir, please continue the series. It would help all of us a lot 🤞🏻The quality you provide is unmatchable. 💥
# GOD Of DSA
Hi I am a 11yr exp java guy was searching for some free course on youtube for DSA came accross your course and i just feel love in it...all in one place that too with java...i must say you have done very awsome work...your name will be there on this earth as long as DSA will be asked in interviews...May Supream Lord Vishnu Bless You..✌🙏
Hi Shubham, which tech stack are you working now?
Favorite Line from all the lectures is: Very Simple Stuff
One of the best tutorials so far in CZcams (Java). Thank you Kunal
Learning DSA has never been this much fun.
Bhaiya isme java language basics se padhai hai kya kyuki Mai beginner hu please reply
@@Siddharth3029 yes. its covering from the basics. go for it
Many thanks, Kunal! 🤛 This lesson was a good opportunity for me to practice loops and conditions. Something that for many more experienced developers surely is daily business. I try to make it a habit to first write the pseudo code and the flowchart for the assignments and then I go over to code the solution in Java, JavaScript and Go. This takes a ton of time, but this way the stuff sticks in my old brain. I appreciate your contribution to free education. 🤝
Wonderful!
Even my proffessor won't teach like that you.Great man kudos to you.
All of your videos from basic to advanced are unavoidable due to your super smart style of teaching. It's a gift for many of us beginner or experienced who so ever I believe.
You're very welcome!
@@KunalKushwaha one biggest plus point in all your teachings , you are successfully able to generate interest on such difficult topics like DSA of folks watching these videos in a true sense
Such a great course , I can't stop myself playing next lectures ...doing it one by one
Awesomeeee🔥 i am literally addicted to this series.. this 2 day gap felt like a lifetime😂..
I uploaded 6 videos in 6 days what else do you want?
@@KunalKushwaha May be he is the one who already know basics 😁
@@KunalKushwaha are na na i didnt mean like that i just meant such is the quality of the content.. it makes waiting worth it😅.. sorry if i choose the wrong words
Bhai CIVO channel p v deveops ka bootcamp mein padha rhe h aur twitch p v Opensource(MLH) k liye kl podcast kiye the...so if you are interested in these, you may follow these videos.
More videos!!!
Every one can teach but no one teach like you 🥰🥰🥰
Waiting for your next video 😍😍🥰
Thanks a lot for such kindness where u r teaching DSA and not charging any penny...
Good stuff 👍 Kunal . This series is gonna be great . Excited or what!
this course is in very detail for begginers
and covers all important concepts
I never stick onto CZcams lectures series for a long time. But this one has my ❤️
Hey seriously I am not getting anything what he is teaching but I completely want to learn what should I do. I don't know anything about coding.
@@iUtkarsh21 first learn C or C++ then you will understand , I also didn't understand anything but after learning C I can understand most of it.
no learn from durga sir no need of c i never learnt it @lakshaydahiya618 @I@@iUtkarsh21
One of the best. This will make pro. Kunal kudos
Yes its really blessing to come through your channel lots of love❣️
thank you finally find a tutor whom gave great content ❤
thank you for such amazing playlist....😍Its really helpfull👍
noone could teach as better as kunal sir,mean my words guys this is the most understanding and easy explained coarse just follow the assignments question to build more confidence ,and see the result after a month that the level is increased,i highly appreciate this work done by kunal sir i wish i could meet and thanks for all this.
Dont't worry ! I am with you
Thanks so much Kunal. You are a blessing.
Its great DSA course ever, first time coding seems interesting😍
This is Amazing bro! Learnt & practiced as well.
52:43 Even if you print the rem variable the answer will be the same i.e. reverse of that num, all you need to do is initialize the rem variable outside the while loop. THANK YOU for a clear explanation
I Must say these videos are CLEAN !
keep on coming kunal ! it's really feels awesome ...
This is the best way of teaching.
love this dude , thanks Kunal for the DSA
In the Video at the instance 34:00 , if we run the program only the first if we enter a valid alphabet then it will show whether it's uppercase or lowercase, but if we right any number it gives output as a Uppercase.
correct code :
import java.util.Scanner;
public class CaseCheck {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
char ch = input.next().trim().charAt(0);
// check wether it's upper case or lower case
// && and
// || or
if(ch >='a' && ch = 'A' && ch
Some of the questions here are easy leetcode questions. Awesome work Kunal
Java DSA ...U MADE THE TOUGH ONE SO EASY . Hats off
You are best, the work which u r doing really God will bless u for this🙏🙏👏👏
you solving questions was an eyeopener
Completed assignment, Awesome explanation.... Moving to next one
This man has removed the fear of java from my mind!
In the way, you explain things, is too good.
great video kunal, hands on learning. Feel so much more confident about programming in java.
Dont't worry ! I am with you
Love this course Sir
It is really amazing 🤩
#Superb series Kunal Bhaiya
#one & only one😎
#Eazy to understand
#No.1 Java+DSA
Great Explanation brother. Really motivating...
honestly speaking, i m in 2nd yr, and this is the first time i could understand while loop, kudos man u r greattt
same here vroo....
Then how did you make it to 2nd year, if you don't even know basic loops 😂
If I could, I would write this in every video: nobody dedicated so much on the internet to teach such complex subjects in a clear, crystal-clear manner, besides the amazing quality. And tks for teaching in English, I am a native Portuguese speaker and I have English as a second language, however, most of the good videos are available in Hindi and have no translation to English. Tk you forever!!
(I have you as a reference in terms of learning, better than all my professor in computer science college adding altogether)
Thank you
@@KunalKushwaha bhyia pls continue DSA series you're much much much better than those paid courses
@@harishrajwani3697 bhai kunal bhaiya ne dsa series complete kiyi to best series hogi
@KunalKushwaha 52:09 why we are adding the numbers but we can simply do ......
public class reversingNumber {
public static void main(String[] args){
int n = 28479;
while (n>0){
int x = n%10;
System.out.print(x);
n = n/10;
}
}
}
Hi Kunal your work is amazing ...I've been working since last 7yrs in IT but I never know how to reverse number & Fibonacci series logic I was just remembering it as I never understood it Thanks brother seriously.
Dammm addictiveee ❤️🔥🔥❤️..may god bless youu 💓
Bro I was planning to buy course of DSA JAVA from coding ninja and suddenly i searched on CZcams and start playing your videos .Now i am addicted to your channel.Thank you for uploading these quality course,you saved my money.❤❤❤
I am enjoying the series by Kunal, literally binge watching this Kunal playlist. I tried to modify the calculator program here and added just a few logic: import java.util.Scanner;
public class Calculator {
public static void main(String[] args) {
// The calculator program tutorial by Kunal;
Scanner input = new Scanner(System.in); // takes in user input
// Calculation logic.
// should be a loop
while (true) {
System.out.println("Enter the operator to use ");
// takes the operand we'll be using
char op = input.next().trim().charAt(0);
if (op == '+' || op == '-' || op == '/'|| op == '*' || op == '%'){
System.out.println("Enter the 2 numbers to use ");
int res = 0;
int num1 = input.nextInt();
int num2 = input.nextInt();
boolean validCalculation = true;
if (op == '+') {
res = num1 + num2;
} else if (op == '-') {
res = num1 - num2;
} else if (op == '/') {
// But we cant divide a number by 0, it will throw an error.
if (num2 != 0) {
res = num1 / num2;
} else {
System.out.println("Hey there, this is not valid as it will return infinity");
validCalculation = false;
}
} else if (op == '*') {
res = num1 * num2;
} else if (op == '%') {
if ( num2 != 0) {
res = num1 % num2;
} else {
System.out.println("Hey there, this is will result to an error, cant have this");
validCalculation = false;
}
}
if (validCalculation){
System.out.println("Your result is " +res);
}
} else if ( op == 'x' || op == 'X') {
break;
} else {
System.out.println("Invalid Operator");
}
}
}
}
Thanks a lot Kunal! Enjoy this section.
This is the best lecture series so far.. Thankyou!
You're very welcome!
kunal bhaiya i know you must be busy but adding a lecture of you doing an open source project using what we have learnt so far in this course will make it absolutely complete because what most of us lack is implementation and it'd mean the world to us if you'd think about it. Thank you for everything
+1
@@iqbalfirdousi9732 +2
+3 totally !!!
fr
Thank you so much for this series
well explained than my college lecturer first i was hating java but now i am loving it
the best series on youtube even paid courses are not like this.. hats of to you kunal
Take precautions before watching this course
You will be addicted to this DSA course and fall in love with DSA 😄😆💯
Keep up the good work Kunal! Cheers!
Excellent job U R Doing 👍🏻👍🏻
Thanku kunal for this amazing playlist😇
bro thanks for providing such a quality content
Great Explanation Sir🙇♂✨🙏❤
Eagerly waiting for other upcoming videos
i have learnt the new approach to find the largest number WOW!
Great work!!!
at 50:59 we can use print without multiplying with 10
public class reverse {
public static void main(String[] args) {
int a=83574;
int nxt=0;
while(a>0)
{
int mod=a%10;
nxt=mod;
System.out.print(nxt);
a=a/10;
}
}
}
it's output is 47538 !!!!!
it is actually fun ....i enjoyed whole video...
51:57 another method to solve this is ,,
class Main {
public static void main(String[] args) {
long n = 198451318728144l;
long rev = 0;
while(rev
In the Video at the instance 6:24 , if we run the program only the first if condition is running , else if will not run ... for that i would suggest everybody to write 20000 in the if condition and 10000 in else if condition.
Example:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int salary = input.nextInt();
if (salary > 20000){
salary += 3000; //salary=salary+3000
} else if (salary > 10000) {
salary += 2000; //salary=salary+2000
}
else {
salary += 1000; //salary=salary+1000
}
System.out.println(salary);
}
}
Thank you so much!! I really mean it.
You are really talented and you know how to teach others. Glad I found your channel to learn DSA. Thanks Kunal!
Bhaiya isme java language basics se padhai hai kya kyuki Mai beginner hu please reply
@@Siddharth3029brother kya tumne yeh start kia?
@@dherya__rakho nahi mai devlop sikh rahu hu abhi baad me dsa karunga
@@Siddharth3029 web dev? But why.... Agar tum Java pehle karte toh tumhe baad mei web d mei bhi asaani hoti
Turned out as an inspirational ♥️
Great job man,love your videos.Kindly do share your journey as a programmer till now.
Thnks kunal for this. Any person can understand this...
great videos
full support kunal bhaiya👍👍👍👍👍👍👍
Hey kunal bhai..in the multiple if else example shouldn't the condition be if ( salary> 10000 && < 20000 ) rather than only the first part? because if i take only the first part and run it and take a salary 22000.. as the program run it will check the first condition and it will satisfy that.. what i am saying is that shouldn't the conditions in multiple if else statements be disjoint?
Thanks for the wonderful lectures, theres not even a single day I skipped your lectures from the past week.
Glad you like them!
Amazing work Kunal ✌️
Thank you for the captions on!
leatraly i don,t have words to say thanks to kunal ❤
Amazing thank u for great content all time
Amazing!! 💯
Great work!!😄
Thanks for saving my career and my money... thanks🙏
You’re welcome
for fibonacci series,
taking 0 as 1st position,
import java.util.Scanner;
public class Fibo {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int a = 0;
int b = 1;
int count = 2;
System.out.println(a);
System.out.println(b);
while (count
I love your answer, my solution was: //Q: Reverse the given integar
int n = 16674;
String numStore = "";
while(n > 0){
int last = n % 10;
String lastString = Integer.toString(last);
numStore += lastString;
n /= 10;
}
int numInt = Integer.parseInt(numStore);
System.out.println(numInt);
public class fibo {
public static void main(String[] args) {
int a=0;
int b=1;
System.out.println(a);
System.out.println(b);
for (int i = 0; i < 8; i++) {
int c=a+b;
System.out.println(c);
a=b;
b=c;
}
}
}
Next Level 🔥🌟
these videos also "make sense !!" ....... I would love to loop my thanks to infinity times
Great video. Love the content