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

8
Ugesedler/Ugeseddel-5 01-10-2025/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KubernetesApiProvider"><![CDATA[{}]]></component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="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$/Ugeseddel-5 01-10-2025.iml" filepath="$PROJECT_DIR$/Ugeseddel-5 01-10-2025.iml" />
</modules>
</component>
</project>

View File

@@ -0,0 +1,82 @@
import java.io.*;
import java.util.Scanner;
public class Opgaver {
public static void main(String[] args) throws FileNotFoundException {
Opgave1.opgave1();
//Opgave2.opgave2();
}
}
class Opgave1 {
public static void opgave1() throws FileNotFoundException {
Scanner file = new Scanner(new File("problem2.html"));
boolean inTag = false;
while (file.hasNextLine()) {
Scanner currentLine = new Scanner(file.nextLine());
String stringInTag = "";
String textOnLine = "";
inTag = false;
while (currentLine.hasNext()) {
String token = currentLine.next();
for (int i = 0; i < token.length(); i++) {
if (inTag == false && token.charAt(i) == '<') {
inTag = true;
} else if (inTag == true && token.charAt(i) == '>') {
inTag = false;
stringInTag = "";
continue;
}
if (inTag == false) {
textOnLine += token.charAt(i);
} else {
stringInTag += token.charAt(i);
}
}
textOnLine += (inTag ? "" : " ");
}
System.out.println(textOnLine + stringInTag);
}
}
public static String readEntireFile(Scanner input) {
String stringFile = "";
while (input.hasNextLine()) {
stringFile += input.nextLine() + "\n";
}
return stringFile;
}
}
class Opgave2 {
public static void opgave2() throws FileNotFoundException {
Scanner console = new Scanner(System.in);
System.out.print("Indtast filnavn/sti: ");
String fileName = console.next();
Scanner file = new Scanner(new File(fileName));
int sum = 0;
int amount = 0;
int max = 0;
int min = 0;
while (file.hasNext()) {
if (file.hasNextInt()) {
int token = file.nextInt();
amount++;
sum += token;
min = (amount == 1 ? token : min); // Min-værdien skal defineres som første tal.
min = (token < min ? token : min); // Min-værdien opdateres hvis token er større end den.
max = (amount == 1 ? token : max); // Samme som min.
max = (token > max ? token : max);
} else {
file.next();
}
}
System.out.println("Gennemsnittet er: " + (double) sum / amount);
System.out.println(
"Min.-værdien er : " + min + " og Maks-værdien er: " + max
);
}
}

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$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,13 @@
<html>
<head>
<title>My web page</title>
</head>
<body>
<p>There are many pictures of my cat here,
as well as my <b>very cool</b> blog page,
which contains <font color="red">awesome
stuff about my trip to Vegas.<p>
Here's my cat now:<img src="cat.jpg">
</body>
</html>

View File

@@ -0,0 +1,4 @@
4 -2 18
15 31
27

View File

@@ -0,0 +1,4 @@
4 billy bob -2 18 2.54
15 31 NotANumber
true 'c' 27

View File

@@ -0,0 +1,2 @@
no numbers here
BAD END

View File

@@ -0,0 +1,12 @@
<html>
<head>
<title>My web page</title>
</head>
<body>
<p>There are many pictures of my cat here,
as well as my <b>very cool</b> blog page,
which contains <font color="red">awesome
stuff about my trip to Vegas.<p>
Here's my cat now:<img src="cat.jpg"
MISSING END TAG IN LINE ABOVE

View File

@@ -0,0 +1,12 @@
<html>
<head>
<title>My web page</title>
</head>
<body>
<p>There are many pictures of my cat here,
as well as my <b>very cool</b> blog page,
which contains <font color="red">awesome
stuff about my trip to Vegas.<p>
Here's my cat now:img src="cat.jpg">
MISSING START TAG IN LINE ABOVE