Task-1-Calculator
Beginner Level
See Home Page
See Task 2 Page
See Task 3 Page
See Information Page
The purpose of this task is to introduce you to Java Methods and handling with numbers.
There are two files for you to look at: Calculator.java, and Calculator2.java.
The first one is a demo code to look at how classes and methods work.
- Classes are like blueprints in which you can create objects out of.
- All these objects have access to the same methods.
- Methods are subprograms that can be reused without rewriting the code.
- e.g. Class = Vehicle. An object of that can be called a car. They all have methods such as drive, brake, turn etc.
Most of the tasks you have to do is on Calculator2.java.
The aim of this is to make it capable of performing the quadratic formula, by breaking it up into smaller parts.
The setup for the methods are there. You just need to add in the right numbers: squaring b; 4AC; square root 4AC etc
![](Images/quadraticEquation.png)
Keywords (completed):
Open this file in the GitHub editor/ Gitpod (Task1.md file) - match keywords with definitions. Copy and Paste.
Keywords:
- Java - A programming language
- Method - A subprogram which can be called many times
- Class - A ‘Cookie Cutter’ which can make objects of that type
- Integer - A whole number
- Float - A number that can use decimals
Definitions:
- A programming language
- A subprogram which can be called many times
- A whole number
- A number that can use decimals
- A ‘Cookie Cutter’ which can make objects of that type
Predict:
System.out.println("Hello World");
- Guess what the output is from the code above: Hello world
- Actual output: See answer here
System.out.println(10 + 10);
- Guess what the output is from the code above: 20
- Actual output: See answer here
Introductory Tasks (Completed):
Main Tasks:
Open calculator2.java
Tips/Hints
- This webpage has a link to check your progress below, and a link to GitHub.
- Going to Github can be easily accessed via the ‘View on GitHub Button’.
- Run code can be done via F5 or right-click and Run Java
- Save your work after each subtask
- Stuck on something else? Look at the information page for help
- A square of a number is a number multiplied by itself (e.g. num1 * num1)
- Multiply in java is the * key
- Square Root: Math.sqrt(X)
Save your work
- Remember to save your work. You can see your progress on the links as well by saving.
- To save your work, enter submit to the command line.
![](Images/submit.PNG)
Calculator 1 status:
See report on Calculator 1
![](Images/calculator1Status.jpg)
Calculator 2 status:
See report on Calculator 2
![](Images/calculator2Status.jpg)
Answers to the programming tasks are in the ‘answer’ branch.
Predict answers:
- Java = A programming language
- Method = A subprogram which can be called many times
- Class = A ‘Cookie Cutter’ which can make objects of that type
- Integer = A whole number
- Float = A number that can use decimals
Optional. Embed an IDE to code here.
Want to code on the webpage?
Steps:
- Go to https://replit.com/ and create an account.
- Once you signed in click on the + icon on the top-right, then import from GitHub.
- Once you do that, you can work on Replit to code rather than Gitpod.
- You can also copy the web address and paste it here.
![](Images/Replit.png)
Don’t be alarmed if there is a 404 error below. If you want, paste your link when you edit this file.