Lektion 1: lösningsförslag
- int result = 5 + 2;
- int result = 5 + 2 * 7;
- int result = (10 + 2) / 3;
- int result = (3 * 8) / (4 * 2);
- string s = "secret123";
- bool access = s == "secret123";
- string s = "secret123";
- bool access = !(s != "secret123");
- int temp = 12;
- bool comfortable = temp >= 18 && temp <= 26;
- int temp = 12;
- bool comfortable = temp == 18 || temp == 19 || temp == 20 || temp == 21 || temp == 22 || temp == 23 || temp == 24 || temp == 25 || temp == 26;
- int age = 35;
- string country = "USA";
- int elected = 1;
- bool eligible = age >= 35 && country == "USA" && elected <= 1;
- int age = 35;
- string country = "USA";
- int elected = 1;
- int billions = 100;
- bool eligible = age >= 35 && country == "USA" && elected <= 1 || billions >= 100;
- double meters = 1.80;
- double kilos = 70;
- double bmi = kilos / (meters * meters);
- double meters = 1.80;
- double kilos = 70;
- double m = meters * meters;
- double bmi = kilos / m;
- double fahrenheit = 100;
- double celsius = (fahrenheit - 32) * 0.56;
- double fahrenheit = 100;
- double x = fahrenheit - 32;
- double celsius = x * 0.56;
- double celsius = 38;
- double x = celsius / 0.56;
- double fahrenheit = x + 32;
- double fahrenheit = 100;
- double celsius = (fahrenheit - 32) * (5.0 / 9);
- double fahrenheit = 100;
- double celsius = (fahrenheit - 32) * ((double) 5 / 9);
- int cash = 100;
- int bank = 500;
- string message = "Din förmögenhet: " + (cash + bank);
- int cash = 100;
- int bank = 500;
- int total = cash + bank;
- string s = "Din förmögenhet: " + total;
- string message = s + " kronor";
- bool x = true;
- bool y = false;
- bool result = !x || !y;
- result
- int kids = 10;
- int candy = 505;
- double portion = (double) candy / kids;
- int seconds = 3735;
- int s = seconds % 60;
- int m = (seconds / 60) % 60;
- int h = seconds / (60 * 60);
- string timer = h + "h, " + m + "m, " + s + "s";