Dies ist eine alte Version des Dokuments!
LU07.A09 - Basic caluclator simple
Prerequisites
- Work type: Individual
- Means of aid: only teaching materials, no websearch, no use of ai.
- Timeframe: 45 Minutes
- Expected result: A browser based calulator which can sum up 2 digits in the easiest way.
Source
- You can take any script an adjust it to your needs.
Assignment
This assignment compraises the programming of a tiny caculator for basic calculation operations, meaning two diggit have to be added together. To do the assignment we need two blocks of diggits-buttons, an operation-button for „+“ and finally an ENTER-Button to execute the operation respectively to receive the result.
Assignment A - 3'
- A01: Create in Webstorm in your directory 07_methods a html file and name it correctly LU07.S09.
- A02: Copy the structure of the sfc (single file component) from a solution of your choice (in that way we don't have to type it manually –> easier and faster)
- A03: Make sure to have
- the assignmen number in <h1> and
- the description in <h3>-format
- A04: Safe it.
Assignment D - Button for diggit 1 - 10'
- B01: Create the buttons 1 to 4 (that shall suffice for our purpose)
- B02: When clicking on one of them the content will be saved in the variable diggit1
Assignment C - Variables - 7'
- C01: A basic calculation 3 + 3 = 6 compraises several variables and their initial values:
- diggit1: 0
- operator: ''
- diggit2: 0
- result: 0
Assignment D - Button for diggit 1 - 10'
- D01: Create the second set of buttons 1 to 4 to set the second diggit. (4 of them shall suffice for our purpose)
- D02: When clicking on one of them the content will be saved in the variable diggit2
Assignment E: Implementation of the calculation - 15'
- E01: To execute our addition-operation we finally need a button ENTER.
- E02: This enter calls a method calcResult(operator).
- E03: Thus the addition is done in the method, correspondingly to the providet operator.
- E04: As a result, after pressing the enter button, the result should be displayed in the screen.