first commit

This commit is contained in:
2025-11-26 13:56:55 +01:00
commit c5f25901e1
188 changed files with 52799 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

5
Ugesedler/Ugeseddel-3 17-09-2025/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,5 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="zulu-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Programmeringsopgaver 17-09-2025.iml" filepath="$PROJECT_DIR$/Programmeringsopgaver 17-09-2025.iml" />
</modules>
</component>
</project>

View 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>

View File

@@ -0,0 +1,96 @@
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
/*Opgave1.printNumbers(15);
Opgave2.processName();
Opgave3.repl("Hello", 3);
Opgave4.printPowersOf2(10);
Opgave4.printPowersOf2NoMath(10);
Opgave5.Opgave5();*/
Opgave6.quadratic(1,3,2);
}
}
class Opgave1 {
public static void printNumbers(int n) {
for (int i = 1; i <= n; i++) {
System.out.print("["+i+"] ");
}
System.out.println();
}
}
class Opgave2 {
public static void processName() {
Scanner scanner = new Scanner(System.in);
System.out.print("\n Skriv dit navn: ");
String name = scanner.nextLine();
String[] splitName = name.split(" ");
System.out.print("Dit navn i omvendt rækkefølge er: "+splitName[splitName.length-1]+", ");
for (int i = 0; i <= splitName.length-2; i++) {
System.out.print(splitName[i]+" ");
}
System.out.println();
}
}
class Opgave3 {
public static void repl(String input, int n) {
for (int i = 1; i <= n; i++) {
System.out.print(input);
}
System.out.println();
}
}
class Opgave4 {
public static void printPowersOf2(int n) {
for (int i = 0; i <= n; i++) {
System.out.print((long)Math.pow(2, i)+" ");
}
System.out.println();
}
public static void printPowersOf2NoMath(int n) {
for (int i = 0; i <= n; i++) {
System.out.print(calculatePowerOf2(2, i)+" ");
}
System.out.println();
}
public static int calculatePowerOf2(int n, int repeat) {
if (repeat == 0) {
return 1;
} else {
return calculatePowerOf2(n, repeat - 1) * n;
}
}
}
class Opgave5 {
public static void Opgave5() {
System.out.printf("%-5s %-15s %-15s %-10s %-10s%n", "Year", "Balance", "Interest", "Deposit", "New Balance");
double balance = 1000.0;
double interest = 0.065;
double deposit = 100;
for (int i = 1; i <= 25; i++) {
double oldBalance = balance;
balance += balance * interest;
double newBalance = balance + deposit;
System.out.printf("%-5d $%-14.2f $%-9.2f $%-9.2f $%-14.2f%n", i, oldBalance, oldBalance * interest, deposit, newBalance);
balance = newBalance;
}
}
}
class Opgave6 {
public static void quadratic(double a, double b, double c) {
double[] x = {0.0,0.0};
for (int i = -1; i <= 1; i += 2) {
x[(i <= 0 ? 0 : 1)] = (-b-(Math.sqrt(Math.pow(b,2)-(4*a*c))*i))/(2*a);
}
System.out.println(Arrays.toString(x));
}
}