Java calculator app 🖩

  Рет қаралды 468,050

Bro Code

Bro Code

Күн бұрын

Пікірлер: 499
@BroCodez
@BroCodez 4 жыл бұрын
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Calculator implements ActionListener{ JFrame frame; JTextField textfield; JButton[] numberButtons = new JButton[10]; JButton[] functionButtons = new JButton[9]; JButton addButton,subButton,mulButton,divButton; JButton decButton, equButton, delButton, clrButton, negButton; JPanel panel; Font myFont = new Font("Ink Free",Font.BOLD,30); double num1=0,num2=0,result=0; char operator; Calculator(){ frame = new JFrame("Calculator"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(420, 550); frame.setLayout(null); textfield = new JTextField(); textfield.setBounds(50, 25, 300, 50); textfield.setFont(myFont); textfield.setEditable(false); addButton = new JButton("+"); subButton = new JButton("-"); mulButton = new JButton("*"); divButton = new JButton("/"); decButton = new JButton("."); equButton = new JButton("="); delButton = new JButton("Del"); clrButton = new JButton("Clr"); negButton = new JButton("(-)"); functionButtons[0] = addButton; functionButtons[1] = subButton; functionButtons[2] = mulButton; functionButtons[3] = divButton; functionButtons[4] = decButton; functionButtons[5] = equButton; functionButtons[6] = delButton; functionButtons[7] = clrButton; functionButtons[8] = negButton; for(int i =0;i
@vickysanth9653
@vickysanth9653 4 жыл бұрын
it would be more easy to understad for beginners like me if you go slower than usual.. because i don't understand many terms like "ActionListener", interfaces etc.. it's like new to me since I'm a beginner..
@sidra3210
@sidra3210 4 жыл бұрын
Nice👍🔥
@shokirovollohberdi
@shokirovollohberdi 4 жыл бұрын
@@komaltandle465 LOL
@agent47hitman75
@agent47hitman75 3 жыл бұрын
@NOA777 the method Double.parseDouble() casts a value to a double type value. the getText() method is used to get the text from the text field. So Double.parseDouble(txtfield.getText()) is actually casting the string values to a double type value of whatever is written in the rext field as we can't perform calculation with string type of values.
@medjl6083
@medjl6083 3 жыл бұрын
@NOA777 The method parseDouble() of wrapper class Double, convert string to double.
@deepeshsingh7717
@deepeshsingh7717 4 жыл бұрын
People are missing out on your amazing content. I am still learning Java, and your content helps a lot.
@Bryysanity
@Bryysanity Жыл бұрын
how are you now on your Java journey?
@kylewc2286
@kylewc2286 11 ай бұрын
​@@Bryysanity Im curious too
@ashkaneghbali2702
@ashkaneghbali2702 3 жыл бұрын
Came here straight after the 12 hour java tutorial. You are Awesome Bro. Keep 'em coming :)
@milesmiller9588
@milesmiller9588 4 жыл бұрын
Started practice with GUI's and this helped a lot!
@AnsarAbbas-ed5ig
@AnsarAbbas-ed5ig 2 жыл бұрын
off course same here bro😎
@AhsanSharief
@AhsanSharief 6 ай бұрын
00:03 How to make a simple calculator program using Java 03:50 Creating a Java calculator app with J buttons and J panel 07:05 Adding text field and buttons to the calculator app 10:42 Creating an array of JButtons 14:32 Adding delete and clear buttons to the calculator app interface. 17:54 Adding buttons to the panel 21:34 Adding functionality to decimal button and various math operations 26:25 Implementing Clear and Delete functionality in Java calculator app 30:17 Added functionality to the negative button, allowing the user to flip the sign of the number displayed in the text field. 33:44 How to make a very simple calculator using Java
@StefaanMeeuws
@StefaanMeeuws 3 жыл бұрын
Most impressive. Very lucid coding. Congrats on teaching me a little more than I knew!
@Sorjen108
@Sorjen108 2 жыл бұрын
This channel is so underrated I went through many tuto on youtube, but none of them was that good(sincerely), and this is in regards to any programming language This developer is Gold
@flyetimadtravel2157
@flyetimadtravel2157 4 жыл бұрын
Bro You are legend. I am not a student I started learning JAVA to make my travel agency CRM.
@EbbieMonch
@EbbieMonch 2 жыл бұрын
This tutorial was very good and even gave the challenge of fixing the Delete and Clear font size while keeping the rest of the numbers and functions font the same size
@slonbeskonechen8310
@slonbeskonechen8310 4 жыл бұрын
Please, don't stop!!! More and more tutorials!!!!
@Zito_from_OHIO
@Zito_from_OHIO 8 ай бұрын
the first sentence (Please, don't stop!!) remember me of a chat i had i chai 😏😏
@Ali42480
@Ali42480 2 ай бұрын
@@Zito_from_OHIO
@alessandroformica6824
@alessandroformica6824 4 жыл бұрын
Thank you, Bro! My prayers to the algorithm.
@kumarkelash4423
@kumarkelash4423 4 жыл бұрын
you are really a great teacher you have made my life easy hahahah... God bless you sir
@zul_afluz
@zul_afluz Жыл бұрын
Extremely helpful. Got my mini project done within 30 minutes referring your source code and guide. Thankkksss a lotttt ☺👏
@rasisulhubbi9316
@rasisulhubbi9316 2 жыл бұрын
I just start learning java a month ago and a little bit confuse what to do, and i found your channel, its really help me to practice
@westonpeabody8010
@westonpeabody8010 2 жыл бұрын
Thanks man. Believe it or not Ive been learning Java for years and until now Ive never actually wrote a fully functional calculator.
@manthanpatki146
@manthanpatki146 3 жыл бұрын
well I am just commenting to support you because this video has been really helpful and i learnt more ways to use GUI in java.
@BlueOrcas
@BlueOrcas 2 жыл бұрын
I knew bro couldn't miss the negative sign before. He just cares for us bros and was testing us to grow stronger💪
@noah77
@noah77 4 жыл бұрын
Cool, this is nice. Awesome video. And also, I have finished creating my AI ChatBot!!
@BroCodez
@BroCodez 4 жыл бұрын
nice! Which app is it for?
@fmsabisai
@fmsabisai Жыл бұрын
This is an amazing tutorial, thumbs up. I would have loved to see how you handled division by 0. I have also noticed that its possible to have multiple dots in a number which would result in an error during calculations.
@yasarcarel
@yasarcarel 10 ай бұрын
if(e.getSource() == decButton) { if(textfield.getText().contains(".")) { String temp = textfield.getText(); textfield.setText(""); for(int i=0;i
@incarnateblizzard4874
@incarnateblizzard4874 6 ай бұрын
little bit late, but came across the tutorial right now. for multiple dots I did (most likely theres a better solution): if(e.getSource() == decButton) { boolean alrDec = false; for(int i = 0; i
@secretchannel2151
@secretchannel2151 4 жыл бұрын
You are a true Bro. Thank you very much sir! Everyone keep commenting, liking and subbing to help the algorithm!
@mansinaidu
@mansinaidu Жыл бұрын
bro this was really awesome .... my sir told it but it was too confusing but your program was clean and neat.... thank you so much .
@karllouiserito
@karllouiserito 3 жыл бұрын
Thanks Bro I've learned something new today about Java especially that GUI.
@கீர்த்திக்வாசன்-ர1ஞ
@கீர்த்திக்வாசன்-ர1ஞ 3 жыл бұрын
awesome broo..keep rocking
@kemann3815
@kemann3815 3 жыл бұрын
Amazing video. That robotic laugh at the end got me 😂
@gyangaha109
@gyangaha109 4 жыл бұрын
yo bro, love it thanks keep up the good work
@Respects103
@Respects103 11 ай бұрын
best yt for coding i learned many things from you thanks you so much bro code
@parkashkumar765
@parkashkumar765 2 жыл бұрын
You always perfect sir because your way of teaching is all the time perfect. Thank you so much sir.🥰
@biplobahmed6509
@biplobahmed6509 2 жыл бұрын
no caption king. learned a lot from you . thnaks for the quality content
@mohammedhh6488
@mohammedhh6488 2 жыл бұрын
Thank you very much for your assistance, you explained the code perfectly. Thumb Up.
@YaroMalik
@YaroMalik 11 ай бұрын
Bro the goat. Just finished learning Java with you and am building my first project with you too
@BigBadBicycle
@BigBadBicycle Жыл бұрын
I just begun with Java and made my own calculator like this. But after finishing and seeing this video, there is a lot of things I could do to definetly reduce my code size.
@muhammadbsoul1459
@muhammadbsoul1459 2 жыл бұрын
Thanks pro Very helpful video Keep going
@suaddacic7728
@suaddacic7728 4 жыл бұрын
Thanks man You explain java better than my teacher
@ChinmayaHelchel
@ChinmayaHelchel 2 жыл бұрын
Thank you @BroCode ☺ It was really up to the point !
@ManuelErica
@ManuelErica 6 ай бұрын
You're the man. Good job!
@thebeginner613
@thebeginner613 2 жыл бұрын
Polich machaa.. You are great 👏🏻👏🏻
@Hypa_Playz
@Hypa_Playz Жыл бұрын
Nice content keep it up!!!🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
@365motivation.9
@365motivation.9 2 жыл бұрын
Bro code,this is an amazing tutorial.Thank you Mann,you taught me alot here.
@grenadine9448
@grenadine9448 3 жыл бұрын
Awesome content !
@bellabrink8610
@bellabrink8610 3 жыл бұрын
Amazing content as always man, thank you!
@gabrielvalentin3106
@gabrielvalentin3106 3 жыл бұрын
Excellent as always bro!
@alireza_programmer
@alireza_programmer 2 жыл бұрын
Thanks a million , It was really nice and perfect for a beginner like me
@halimaomar9820
@halimaomar9820 2 жыл бұрын
I had a few problems with this application and I fixed one. It looks like when you use the negative button you can't click it first then click the number button you want to be negative. It will cause the program to crash. To fix this problem you can use a try and catch method plus a NumberFormatException. The NumberFormatException is an unchecked exception in Java that occurs when an attempt is made to convert a string with an incorrect format to a numeric value. Therefore, this exception is thrown when it is not possible to convert a string to a numeric type (e.g. int, float). It has this problem with negative values. However, the negative button works when you click the number button first then click the negative button. I still put this exception in just in case someone clicks the negative button first. It isn't a great fix because I would like the negative button to work both ways so it won't matter which you click first the number or the negative button. When I figure this out then I will update folks. First, I will attempt to replicate what my phone calculator does with negative buttons. They have a +/- option that has a few different behaviors that I can implement. The second problem I identified is that the functionality of the negative button doesn't work. I checked Bro Code's source code and copied then pasted it on my Eclipse file but still has the same problem. I knew it would but I wanted to make sure it wasn't just me. When you trying adding or multiplying or dividing a number against a negative number it will convert the negative number to -1. No matter what value your negative number is. For example it's -8, it will convert it to -1. Example 1, 3 * -8 = -24, but the calculator will process the equation like this: 3 * -1 = -3. I think maybe I can add a case to the switch statement so I'm going to try that first. Or I can add a loop to the negative button to address the -1 problem. As I said before, when I have solutions for this then I will post it to my comment thread.
@halimaomar9820
@halimaomar9820 2 жыл бұрын
Update: I found a solution to the problem I identified with negative numbers. This solution I tested and it works. Negative value numbers won't automatic be converted to -1 but will have the value you intended. Code: if (e.getSource() == negButton) { double num = Double.parseDouble(textfield.getText()); if (num >= 0) { double resultneg = num * -1; textfield.setText(resultneg + " "); } else { double resultpos = num * -1; textfield.setText(resultpos + " "); } If you notice I changed the button to no longer just be a negative button but a +/- button. I did this because of the calculator apps today on phones and computers are setup with +/- functions.
@halimaomar9820
@halimaomar9820 2 жыл бұрын
Full solution code fixing all the bugs/errors: try { if (e.getSource() == negButton) { double num = Double.parseDouble(textfield.getText()); if (num >= 0) { double resultneg = num * -1; textfield.setText(resultneg + ""); } else { double resultpos = num * -1; textfield.setText(resultpos + ""); } } } catch (NumberFormatException num) { System.out.println( "NumberFormatException occurred"); }
@Rakavi-h4f
@Rakavi-h4f 3 ай бұрын
​@@halimaomar9820 if else condition to check num > 0 or less than or equal to zero , pretty much does the same function as the original bro code.Though it checks explicitly,the results are the same Btw, the two possible errors that you have spotted out are correct but unfortunately there is no solution for those in your code
@orlandohunter2785
@orlandohunter2785 3 жыл бұрын
Bro! These videos are awesome 👏
@mohdaman5928
@mohdaman5928 2 жыл бұрын
i truly learn a lot man thanks
@athulretnakar1907
@athulretnakar1907 3 ай бұрын
Thankyou for your valuable content 😍
@kampfer6375
@kampfer6375 2 жыл бұрын
Very well explained 👍
@LiyaAi-fm9ec
@LiyaAi-fm9ec 5 ай бұрын
Very beautiful, Love it!
@ritikrajput2894
@ritikrajput2894 Жыл бұрын
Wonderful Tutorial
@JEE-nf1cv
@JEE-nf1cv Жыл бұрын
This was indeed Helpful brother Thanks for the tutorial
@animegaming7116
@animegaming7116 Жыл бұрын
the package come back as error what to do
@shibildas
@shibildas 2 жыл бұрын
Bro, that was awesome ❤️
@B_lla008
@B_lla008 Жыл бұрын
thanks for clean work it really help me !you are super good :)
@quikmath8071
@quikmath8071 2 жыл бұрын
Awesome tutorial
@anilsilwal1773
@anilsilwal1773 3 жыл бұрын
Great teaching
@wolanus
@wolanus 4 жыл бұрын
Another great video. Thanks!
@alvydagr8108
@alvydagr8108 2 жыл бұрын
Wow even though your style is different, its super easy to understand and frankly, might make me do my calculator over just because It seems easier the way you did it
@HenocDossou
@HenocDossou Жыл бұрын
Very cool! Helped me alot!
@khusanbekgafurov
@khusanbekgafurov 2 жыл бұрын
Awesome job I like it Thanks
@athenkosinyombolo4275
@athenkosinyombolo4275 3 жыл бұрын
This was really helpful
@helpdesk9535
@helpdesk9535 3 жыл бұрын
Thanks for the help Big Bro!
@etude5942
@etude5942 6 ай бұрын
Thank you so much for the perfect explanation ❤❤❤❤😭
@sci-figameguy8241
@sci-figameguy8241 3 жыл бұрын
Hey I was wondering if you could help me, I'm making this using IntelliJ right now and at 6:40 when I run it to check if a frame comes up I get the error: "Error: Could not find or load main class Main" and I see you don't have a main class either but for some reason yours works?
@mahaalibrahim7934
@mahaalibrahim7934 4 жыл бұрын
That’s was a lot of code thanks for your effort
@Ahmad-jc7by
@Ahmad-jc7by Жыл бұрын
so enjoyable, thanks for this Man
@omeraran9398
@omeraran9398 3 жыл бұрын
I love your channel.
@sudhikrishnana9778
@sudhikrishnana9778 2 жыл бұрын
Great program👍👍👍
@Dontwatchthischannel
@Dontwatchthischannel 5 ай бұрын
Incase you guys didnt know, calc is short for calculator, im just speaking in slang...
@meguminsatou1591
@meguminsatou1591 Жыл бұрын
man Thank you i really need this tutorial for my computer programming 2
@manasapanda9248
@manasapanda9248 2 жыл бұрын
Amazing video I really enjoy this as this is very useful in my program
@maikemvictorine9100
@maikemvictorine9100 2 жыл бұрын
Simple and underatandable
@ahmedshifa
@ahmedshifa Жыл бұрын
Amazing content, thank you!
@djziomsuper
@djziomsuper 3 жыл бұрын
Great video!
@Sub-w3x
@Sub-w3x 2 жыл бұрын
Very Hard working of ur life shows
@cutie3127
@cutie3127 Жыл бұрын
Your amazing Content makes me to passionate about java more... I thought to left but ...
@garvitarora4960
@garvitarora4960 11 ай бұрын
Also my comments on you is "Thanks you very much, Bro!"
@soumelee5661
@soumelee5661 Жыл бұрын
thanks bro for this video!! very helpful :)
@Gaminiheraliyawala
@Gaminiheraliyawala Жыл бұрын
Dear Bro you are simply amazing... ❤❤💐💐being sooo... generous in sharing your wealth of knowledge and you certainly deserve a very big appreciation for making me impressed to learn Java programming. God Bless You Bro...🙏🙏. I really loved it and impatient to try it ASAP..... 👌👌👍👍
@Sapocrate
@Sapocrate 3 жыл бұрын
Thanks! (I appreciate also the 420 on the preview)
@divyakale1271
@divyakale1271 Жыл бұрын
Thanks Wonderful video ! This video is easy to understand and very helpful.
@omersond4891
@omersond4891 3 жыл бұрын
very helpful video. i understand for loops, if() more than before
@ThunderHockeyTFL
@ThunderHockeyTFL 3 жыл бұрын
big thanks, very helpful video! subbed
@kkirs9561
@kkirs9561 2 жыл бұрын
great video tbf
@alien3200
@alien3200 Жыл бұрын
20:35 He was scared for life 😂😂
@letsgame108
@letsgame108 2 жыл бұрын
Thank you so much bro. this is really amazing
@ОлегДомащенко-ы7б
@ОлегДомащенко-ы7б Жыл бұрын
great example. Thanks
@ashnasanam217
@ashnasanam217 3 жыл бұрын
Underrated!
@ThePraQNome
@ThePraQNome Жыл бұрын
Great tutorial, thank you.
@abdialemu8391
@abdialemu8391 Жыл бұрын
you are a hero!
@chiyuzhang3089
@chiyuzhang3089 Жыл бұрын
Thanks Bro, great video!
@ryandavis710
@ryandavis710 3 жыл бұрын
Great tutorial
@ShahzadKhan-jg3hl
@ShahzadKhan-jg3hl 3 жыл бұрын
Well defined. Thank you.
@Dejuk22
@Dejuk22 Жыл бұрын
well done bro🙌 thank you!!
@vasilizaitsev7246
@vasilizaitsev7246 3 жыл бұрын
Great work bro
@raziqraz5043
@raziqraz5043 3 жыл бұрын
Thank you bro Awesome video
@lener6345
@lener6345 3 жыл бұрын
Congratulations you have cracked the youtube algorithm
@Baltazar_Gunar
@Baltazar_Gunar 3 жыл бұрын
i just finish second book about java. A Beginners Guide and Complete Reference from Herbert SCHİLDT. I was looking for an example of real GUI software that wasn't beyond my knowledge and actually did something. So I could get an idea of ​​the general programming structure. Your video help me a lot about this. Thank you.
@infotechlab
@infotechlab 2 жыл бұрын
hey bro! thanks a lot for this amazing content..
@rudranagariya8546
@rudranagariya8546 3 жыл бұрын
Thank you so much bro you are the only best coder
@stanislavdimitrov1643
@stanislavdimitrov1643 Жыл бұрын
Great, fantastic. It may seem a little but too advanced at the beginning, but you can try it and see:)
@konsti02
@konsti02 3 жыл бұрын
this is great! Thank you
Build this JS calculator in 15 minutes! 🖩
15:20
Bro Code
Рет қаралды 747 М.
Making a Game with Java with No Java Experience
8:41
Goodgis
Рет қаралды 742 М.
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
Java GUI Tutorial - Make a Login GUI #100
19:49
Alex Lee
Рет қаралды 567 М.
Learn Java in 15 Minutes (seriously)
19:50
ForrestKnight
Рет қаралды 186 М.
you will never ask about pointers again after watching this video
8:03
God-Tier Developer Roadmap
16:42
Fireship
Рет қаралды 7 МЛН
How To Make A Calculator Using HTML CSS And JavaScript
19:01
GreatStack
Рет қаралды 973 М.
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1,1 МЛН
I built my own 16-Bit CPU in Excel
15:45
Inkbox
Рет қаралды 1,7 МЛН
7 Design Patterns EVERY Developer Should Know
23:09
ForrestKnight
Рет қаралды 248 М.
Create Rock Paper Scissors in Java in 10 Minutes
10:24
Coding with John
Рет қаралды 124 М.
Can I 100% Superliminal and Get a Refund?
23:36
Gronf
Рет қаралды 357 М.