first commit
This commit is contained in:
11
Ugesedler/Ugeseddel-2 10-09-2025/Opgaver/Opgaver.iml
Normal file
11
Ugesedler/Ugeseddel-2 10-09-2025/Opgaver/Opgaver.iml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
126
Ugesedler/Ugeseddel-2 10-09-2025/Opgaver/src/Opgaver.java
Normal file
126
Ugesedler/Ugeseddel-2 10-09-2025/Opgaver/src/Opgaver.java
Normal file
@@ -0,0 +1,126 @@
|
||||
public class Opgaver {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Opgave1.opgave1(10.0,20.0,4.0,2.0));
|
||||
/*Opgave2.opgave2();
|
||||
Opgave3.opgave3a();
|
||||
Opgave3.opgave3b();
|
||||
Opgave3.opgave3c();
|
||||
Opgave4.opgave4();
|
||||
Opgave5.opgave5();*/
|
||||
Opgave6.opgave6();
|
||||
}
|
||||
}
|
||||
|
||||
class Opgave1 {
|
||||
public static double opgave1(double v0, double t, double a, double s0) {
|
||||
System.out.println("\nOPGAVE 1:\n");
|
||||
double s = s0 + v0*t+(0.5*a*(t*t));
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
class Opgave2 {
|
||||
public static void opgave2() {
|
||||
System.out.println("\nOPGAVE 2\n");
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
System.out.print(" " + i*i);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
class Opgave3 {
|
||||
public static void opgave3a() {
|
||||
System.out.println("\nOPGAVE 3\n");
|
||||
System.out.println("3a:");
|
||||
for (int g = 1; g <= 3; g++) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (int j = 1; j <= 3; j++) {
|
||||
System.out.print(i);
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
public static void opgave3b() {
|
||||
System.out.println("\n3b");
|
||||
for (int g = 1; g <= 3; g++) {
|
||||
for (int i = 9; i >= 0; i--) {
|
||||
for (int j = 1; j <= 5; j++) {
|
||||
System.out.print(i);
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
public static void opgave3c() {
|
||||
System.out.println("\n3c:");
|
||||
for (int g = 1; g <= 3; g++) {
|
||||
for (int i = 9; i >= 0; i--) {
|
||||
for (int j = 1; j <= i; j++) {
|
||||
System.out.print(i);
|
||||
}
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Opgave4 {
|
||||
public static void opgave4() {
|
||||
System.out.println("\nOPGAVE 4:\n");
|
||||
int a = 1;
|
||||
int b = 1;
|
||||
System.out.print(a + ", " + b + ", ");
|
||||
for (int i = 2; i<12; i++) {
|
||||
int c = a + b;
|
||||
System.out.print(c + ", ");
|
||||
a = b;
|
||||
b = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Opgave5 {
|
||||
public static void opgave5() {
|
||||
int number = 1;
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
printLines(6-number);
|
||||
for (int j = 1; j <= number; j++) {
|
||||
System.out.print(2*i-1);
|
||||
}
|
||||
printLines(6-number);
|
||||
number++;
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
public static void printLines(int amount) {
|
||||
for (int j = amount; j >= 0; j--) {
|
||||
System.out.print("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Opgave6 {
|
||||
public static void opgave6() {
|
||||
System.out.println("\nOPGAVE 6\n");
|
||||
printStairs(5);
|
||||
|
||||
}
|
||||
public static void printStairs(int repeatAmount) {
|
||||
for (int i = repeatAmount-1; i >= 0; i--) {
|
||||
System.out.print("\n" + repeatString(i*5, " ") + " o ******" + repeatString((repeatAmount-i-1)*5, " ") + "*");
|
||||
System.out.print("\n" + repeatString(i*5, " ") + " /|\\ *" + repeatString((repeatAmount-i)*5, " ") + "*");
|
||||
System.out.print("\n" + repeatString(i*5, " ") + " / \\ *" + repeatString((repeatAmount-i)*5, " ") + "*");
|
||||
}
|
||||
System.out.println("\n" + repeatString((repeatAmount+1)*5+2, "*"));
|
||||
}
|
||||
|
||||
public static String repeatString(int amount, String string) {
|
||||
String returnString = "";
|
||||
for (int i = 0; i < amount; i++) {
|
||||
returnString = returnString + string;
|
||||
}
|
||||
return returnString;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user