In this part of the project we will be working on getting our display to actually output the numbers that we click now that they are in a list that we can access the items in out list.
We add this code to all of our number buttons so that we can add their values to the calculator. They will look something like this.
From here we can begin working on our operations buttons. At the moment however I do not know how to code numbers that are bigger than a single digit so we might have to continue this project another time.
Ill work on these operations buttons in the future but for right now I will move to a slightly simpler project for a little while until I can figure out how to make my calculator work properly.
Thank you all for reading sorry this post is shorter than usual there will be 2 coming out tomorrow.
In this lesson we will be going over the basic code for the buttons on our calculator. Seeing as we already have the basic UI we can now focus on making the actual calculator work. To do this we will need a list.
These will be my variables as of right now
The reason these images have the yellow triangle is because they have not been called/used yet in my program there is no other error with them.
Now that we have established some variables I will need to start adding basic code to the buttons that will allow us to add their values to our inputs list and then eventually to our results box.
This is the code for numbers 1-5
And this is the code for buttons 6-0
That’s pretty much it for this blog it was a short one as I didn’t really have that much done because I’m on break but next lesson we should be able to program the operators and these inputs in our list should be in our results box as well.
Now that we set up a basic calculator design screen we can work on adding buttons to make it work. Because at the moment all it does is sit there and look nice.
The first buttons we are going to add are going to be the number buttons that will add text to the calculator output. Once you have added all the actual buttons to the calculator we will number it 1-9
Once we add our buttons we will need to set up our sign buttons for the division sign multiplication equals and plus as well as the decimals place.
Now we will add some finishing touches such as the response text box and we are basically done in terms of designing the UI or user interface of our app.
This is our final result for this blog I hope you enjoyed and as always feel free to check out my you tube channel for gaming and cooking videos: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg
In this lesson we will finally be using the actual app maker screen to make some real running code and this will be our final lesson before we make our calculator. Because it wont make much sense if we don’t know how to use the screen it will be made on.
Our first main screen items will be buttons. These will be what trigger actions on our screen. Making them an essential part of our overall app. To access the layout of our screen we will need to select the design tab. Like this:
This now gives us access to all the possible items that we can add to our screen I will begin to make the base shape of our calculator. Using the image item in our toolbox.
This is how I decided to design my basic calculator screen but you can design it however you would like. These buttons don’t actually do anything so I will need to add my own buttons on top of them to actually start coding but I will do that later. As far as this lesson goes That’s all we really need to do as each persons calculator design will likely be different.
As always feel free to check out my youtube channel for cooking and gaming thingss. link: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg
These operators are also pretty important to as it says compare things. They are called boolean(s) and generally have 2 choices that then checked with an operator like and, or , and not.
In Java script however they are typed like this “&&” and is 2 and signs or is two “||” and not is “!=” so the way a boolean expression would be formatted is console.log (“Hello” && “World”); and it should work like this.
The reason this doesn’t work is because it isn’t like an addition sign and it is meant to compare conditions that need to be met in order for something to word and not to fuse words together.
But now we should work on the actual uses of these operators. Say you needed to see if the temperature on a thermostat was at max or min you would make a variable temperature and write a piece of code saying if (temperature >= 90 C || temperature <= 10 C) Then display “This temperature is not on the thermostat”
As you can see our operator works just as intended and so did the code the only problem is that it has to be reset and rerun every time the temperature is updated. So we need to start working in the actual app designer which allows us tons more possibilities.
But we need to cover one final thing before that which is our signs which include >,<,>=,<=,=,!=. They mean greater than, less than, greater than or equal to, less than or equal to, equal to, and not equal to. These will also be used in combination with our not’s, and’s, and or’s to compare lots of data and information as I did above these are pretty self explanatory however.
Thank you all for reading todays blog I hope you enjoyed and be sure to check out my youtube channel for cooking and gaming videos. Link: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg
This lesson is essentially a continuation of lesson one but it has information that is just as crucial. So we are just going to continue from where we left off.
So as I said before you can only add strings. As these inputs are rightfully not viewed as numbers. Which gives us some pretty interesting options but it also limits us at the same time.
For example the code above will give us the same output as the input “Hello World”
As you can see both lines of code resulted in the same output but one thing I forgot to mention is that if you are using the addition operator you need to add a space after each word in the sentence otherwise they will end up as one word.
But enough about the addition operator lets use the other operators with numbers.
The first operator that we should use is the subtraction operation which works opposite to the addition obviously and it subtracts one value from the other. The same way it would work in a math problem but it looks a little bit different
Just as expected our result from 10-1 came out to 9. The other 2 main operators work the same way which are division and multiplication. Which means they work the same way they would in a regular math problem. The only difference is what symbols are being used which for multiplication is the star “*” and for division is the backslash “/”.
And yes in case you are wondering 9 is my favorite number. But the next thing we can do with these operators is the most useful in my opinion which is combining them to solve math problems very quickly which can get us to our first project which will be making a calculator! But we still have a few lessons before that. Anyway here are some examples of combining operators to solve some equations
As you can see these operators can be used to a near infinite scale and they can calculate all these different equations in an instant which will be the main base for our calculator project that we will be starting soon.
Thank you all for reading and feel free to check out my YouTube channel where I upload video game and cooking things link: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg
This will be my first time “teaching” anyone Java Script but I will do my best in this lesson and the next couple to explain the very basics of the language and how it works.
The first thing that you need to understand is that every coding language has a syntax. This is the way that the code is written and what specific signs or symbols may need to be typed in to make it work/run. The most basic and arguably most important syntax in Java Script is the semicolon “;”. This handy character allows us to essentially finish our lines of code in Java Script letting the computer know that we are done typing into this specific line of code. Forgetting to type this symbol at the end of lines of code is the most basic error that is made by beginners but it is not a big deal as websites such as code.org let you know when this happens
This is what it looks like in code.org when there is no semicolon at the end of a line of code. When there is it should look like this.
You should be able to see the number and that indicates the line of code your on and that you have no errors. The yellow caution signs indicate a minor error in your code such as a slightly incorrect syntax or a missing semicolon however if there is a large red square that indicates a big error in your code that will cause it to not run.
Can you spot the error? The problem is there is no parenthesis around the quoted text hello world. This causes the computer to think you are typing out one solid command that says in console log hello world as opposed to in console log display text hello world.
The final part of this lesson will go over the first place we will apply our coding knowledge, The console log. The console log is essentially a separate mini code player that can be used primarily to display text. We can use the variable operator console.log () to display numbers and console.log (“”) to display text or strings. Strings are just a fancy way of saying text that is used by computers. Strings need the quotation marks to identify themselves because they work differently than numbers.
These are the exact same code using the division operator however one is a number being divided the other is a string. The string cannot be divided so this becomes the output for the code
It becomes 10 which is the correct output for out first line of code but it becomes NaN or not a number for our second line of code. This is because strings can only be used with the addition operator. But I will get into that next lesson.
Thank you all for reading I hope you enjoyed and as always feel free to swing by my YouTube channel where I just uploaded a new video!
Its been quite a while since I’ve uploaded anything on my website and the main reason for that was truly that I didn’t think about it and prioritize correctly for the last almost year. I’m going to make sure to not make that mistake again and not make anymore excuses so I’m going to be uploading between 2-4 blog posts a week as well as consistent cooking content on my YouTube channel, which I will link below. This blog will still be coding centered but I have been talking about and thinking for a while to switch from block code like the format used in Scratch to Java Script. Which is exactly what I will be doing, however if you ever have any questions about anything I’m doing or have done whether it’s Scratch or Java Script feel free to leave a comment and I will do my best to get back to you as soon as possible. The main reason I have decided to make this switch is because I just entered my Freshman year of high school and I’m taking an AP Computer Science principles class. We focus on the use of Java Script to develop apps that perform specific functions. The main website I use is code.org which is a great free platform for any beginner
I would highly recommend checking them out but another place that you can use as a place to code is Khan academy. I’ve found that their lessons are a little bit less challenging and have more instruction where as code.org has more individual paced lessons which allow for more creative freedom. Unfortunately that’s all I have to talk about for today’s post but tomorrow I will be starting lesson one in my own intro to Java Script course feel free to stop by and read all about the wonderful world of Java.
Thank you for reading this blog post it means a lot feel free to stop by my YouTube channel for cool cooking videos cooking is one of my favorite hobbies and I like to think I’m pretty good. I’ll be uploading another recipe on their tomorrow. Link: https://www.youtube.com/channel/UCrlNUqQVBxLIbdltHQBdcYg
If you guys remember before quarantine in late 2019 I made a Minecraft server for bedrock edition. But unfortunately because of not only quarantine but some technical diffuculties caused me to cancel this project/server so now I am going to be making a minecraft java edition server.
So this post will be an update on my progress over the next couple of months.
But the first thing you need to do before starting you very own server is learn how to set up a functioning server. This will require you to have a hosting company/website. But seeing as my server is quite small I am using this great free website called aternos.
This website allows you to have a free server hosted with up to about 100 players with all the forge mods that you would need. It also allows you to do lots of things on your server that would usually cost money with other hosting services.
I will be using this hosting website along with forge to create my server and it should be up an functional by the end of the year hopefully.
That’s pretty much it this post was just an update on how I will be restarting my server on Minecraft java edition. Check out my YouTube channel where I upload daily livestreams or videos.
The holidays will be interesting this year as new rules and regulations are being put in place as the pandemic is getting worse. An example of these new laws are that if you are travelling in the united states and you are going to be staying in another state you must quarantine yourself for 14 days. This will cause lots of problems when famillies are trying to get together for the holidays.
Usually when my family celebrates the holidays we visit my grandparents and other family because they live far away so we don’t get to spend much time together. But this year we cant so instead we had to celebrate thanksgiving by ourselves at our house as we could not fly or drive to their house.
This is causing issues with many famillies as they likely had plans with loved ones over the break but because the pandemic is only getting worse these plans had to be cancelled. But on the bright side we are getting closer to getting a publicly available vaccine that will allow us to once again be able to visit our loved ones.
But for now it is essential that we keep up social distancing, wash our hands frequently, and wear masks. These are all important things to do to help slow the spread of the virus. Thanks to all the first responders and scientists out there who are on the frontlines of trying to battle this vrius. Even though it is tough we can and will get through it!