====== LU07.A10 - Basic caluclator - TBD ====== ===== Prerequisites ===== * Work type: Individual * Means of aid: only teaching materials, no websearch, no use of ai. * Timeframe: 40 Minutes * Expected result: A browser based calulator which can sum up 2 digits. ===== 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.S10**. * A02: Copy the structure of the sfc from a solution of your choice (in that way we don't have to type it manually --> easer and faster) * A03: Make sure to have * the assignmen number in

and * the description in

-format * A04: Safe it. ===== Assignment B - Variables - 5' ===== * B1: A basic calculation **3 + 3 = 6** compraises several variables: diggit1, operator, diggit2 and result * **diggit1 = 0**, * **diggit2 = 0**, * **operator = ''** * **result** ===== Assignment C - Button for diggit 1 - 5' ===== * C01: Create 10 (0 - 9) * C02: When clicking on one of them the content will be saved in the variable **diggit1** ===== Button for diggit2 - 5' ===== * C03: Furthermore we need four new buttons for the operation we want to conduct. Nun These arePlus * **Plus +"" * **Minus -** * **Mal* ** * **Geteilt /** * C02: When clicking on one the operator-button the variable **operator** will be set. #### Übungen 21 C - Buttons für die Operatoren - 10' * A21.5: Nun willen wir die vier Buttons erstellen für unsere Basis-Rechenarten Plus, Minus, Mal und Geteilt. * A21.6: Beim CLICK des jeweiligen Buttons wird die Methode setOperator aufgerufen, die die Variable operator mit der Rechenoperation festlegt.. #### Übungen 21 D - Buttons für diggit1 - 5' * A21.7: Erstellen Sie die Buttons 0 - 9 für die zweite Zahl diggit2. Beim CLICK wird der entsprechende Wert in die Variable diggit2 geschrieben. #### Übungen 21 E - Buttons für diggit2 - 10' * A21.8: Jetzt brauchen wir noch einen Button RESET, was mittels der Methode reset() die Werte der Variable diggit1, diggit2, operator und result auf 0 setzt. * A21.9: Zum Abschluss brauchen wir noch einen Button CALCULATE, das die Berechnung mittels der Methode calc() berechnet. Es speichert das Ergebnis in der Variablen result. * A21.10: Geben Sie die jeweiligen Werte der diggit1, diggit2, operator und result am Monitor aus. ===== Solution ===== [[en:modul:m291:learningunits:lu07:loesungen:10|Lösung]] ===== Vocabulary ===== ^ English ^ German ^ | ... | ... | ---- [[https://creativecommons.org/licenses/by-nc-sa/4.0/|{{https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png}}]] Volkan Demir