first commit
This commit is contained in:
46
Programering afleveringsopgave nr. 1/Hjemmeopgave.java
Normal file
46
Programering afleveringsopgave nr. 1/Hjemmeopgave.java
Normal file
@@ -0,0 +1,46 @@
|
||||
public class Hjemmeopgave {
|
||||
public static void main(String[] args) {
|
||||
Opgave2.opgave2();
|
||||
Opgave3.opgave3();
|
||||
Opgave4.opgave4();
|
||||
}
|
||||
}
|
||||
|
||||
class Opgave1 {
|
||||
public static void opgave1() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class Opgave2 {
|
||||
public static void opgave2() {
|
||||
double x = 7.2;
|
||||
System.out.println(1 + 3 + x + x + x + x + x + 5 / 4 * 2);
|
||||
}
|
||||
}
|
||||
|
||||
class Opgave3 {
|
||||
public static final int LINES = 3;
|
||||
public static void opgave3() {
|
||||
for (int i = 1; i <= LINES ; i++) {
|
||||
for (int j = 1; j <= LINES; j++) {
|
||||
System.out.print("+-");
|
||||
}
|
||||
System.out.println("+");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Opgave4 {
|
||||
public static void opgave4() {
|
||||
for (int i = 0; i <= 30; i++) {
|
||||
if (i % 5 == 0) {
|
||||
System.out.println((i % 3 == 0 ? "Fizz" : "") + "Buzz");
|
||||
} else if (i % 3 == 0) {
|
||||
System.out.println("Fizz");
|
||||
} else {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user