akuma
akuma
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
in the end i just submitted as it is since i racked my brain the whole day and couldn't figure out the issue
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
and apparently the readMessages method is supposed to have no arguments
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
yeah
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
if you want, i can also send a screenshot of the instructions given to us
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
then i landed on that one
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
and one by one i fixed all the errors that popped up in codegrade
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
we only got basic instructions on which classes to create, what each class is supposed to have
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
not sure how to do that, sorry
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
yes, it is running smoothly on my own computer, but when codegrade runs it, it gives me the error i got above
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
so i'm not that good
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
and i am aware that here's probably more optimized ways i can write the code but i'm very new to java
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
public static void writeConversation() {
try {
PrintWriter writer = new PrintWriter("Conversation.txt");
for (String message : messages) {
writer.println(message);
}
writer.close();
} catch (FileNotFoundException e) {
System.out.println("File not found.");
}
}
public static void writeConversation() {
try {
PrintWriter writer = new PrintWriter("Conversation.txt");
for (String message : messages) {
writer.println(message);
}
writer.close();
} catch (FileNotFoundException e) {
System.out.println("File not found.");
}
}
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
if (first.compareTo(second) > 0) {
String temp = messages[k];
messages[k] = messages[l];
messages[l] = temp;
}
}
}
} catch (FileNotFoundException e) {
System.out.println("File not found.");
}
if (first.compareTo(second) > 0) {
String temp = messages[k];
messages[k] = messages[l];
messages[l] = temp;
}
}
}
} catch (FileNotFoundException e) {
System.out.println("File not found.");
}
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
public static void readMessages() {
try {
Scanner reader1 = new Scanner(new File("Person1.txt"));
Scanner reader2 = new Scanner(new File("Person2.txt"));
String[] messages1 = new String[10];
String[] messages2 = new String[10];
int i = 0;
int j = 0;

while (reader1.hasNextLine()) {
messages1[i] = reader1.nextLine();
i++;
}

while (reader2.hasNextLine()) {
messages2[j] = reader2.nextLine();
j++;
}

reader1.close();
reader2.close();

messages = new String[i + j];
for (int k = 0; k < i; k++) {
messages[k] = messages1[k];
}

for (int k = 0; k < j; k++) {
messages[i + k] = messages2[k];
}

for (int k = 0; k < messages.length; k++) {
for (int l = k + 1; l < messages.length; l++) {
int firstWhiteSpace = messages[k].indexOf(" ");
int secondWhiteSpace = messages[k].indexOf(" ", firstWhiteSpace + 1);
int thirdWhiteSpace = messages[k].indexOf(" ", secondWhiteSpace + 1);
DateTime first = new DateTime(messages[k].substring(firstWhiteSpace + 1, thirdWhiteSpace));

int firstWhiteSpace2 = messages[l].indexOf(" ");
int secondWhiteSpace2 = messages[l].indexOf(" ", firstWhiteSpace2 + 1);
int thirdWhiteSpace2 = messages[l].indexOf(" ", secondWhiteSpace2 + 1);
DateTime second = new DateTime(messages[l].substring(firstWhiteSpace2 + 1, thirdWhiteSpace2));

public static void readMessages() {
try {
Scanner reader1 = new Scanner(new File("Person1.txt"));
Scanner reader2 = new Scanner(new File("Person2.txt"));
String[] messages1 = new String[10];
String[] messages2 = new String[10];
int i = 0;
int j = 0;

while (reader1.hasNextLine()) {
messages1[i] = reader1.nextLine();
i++;
}

while (reader2.hasNextLine()) {
messages2[j] = reader2.nextLine();
j++;
}

reader1.close();
reader2.close();

messages = new String[i + j];
for (int k = 0; k < i; k++) {
messages[k] = messages1[k];
}

for (int k = 0; k < j; k++) {
messages[i + k] = messages2[k];
}

for (int k = 0; k < messages.length; k++) {
for (int l = k + 1; l < messages.length; l++) {
int firstWhiteSpace = messages[k].indexOf(" ");
int secondWhiteSpace = messages[k].indexOf(" ", firstWhiteSpace + 1);
int thirdWhiteSpace = messages[k].indexOf(" ", secondWhiteSpace + 1);
DateTime first = new DateTime(messages[k].substring(firstWhiteSpace + 1, thirdWhiteSpace));

int firstWhiteSpace2 = messages[l].indexOf(" ");
int secondWhiteSpace2 = messages[l].indexOf(" ", firstWhiteSpace2 + 1);
int thirdWhiteSpace2 = messages[l].indexOf(" ", secondWhiteSpace2 + 1);
DateTime second = new DateTime(messages[l].substring(firstWhiteSpace2 + 1, thirdWhiteSpace2));

33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
hold on i'll send the methods
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
uh
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
import java.util.*;
import java.io.*;

public class Main {
public static String[] messages;
public static void main(String[] args) {
readMessages();
writeConversation();
}
import java.util.*;
import java.io.*;

public class Main {
public static String[] messages;
public static void main(String[] args) {
readMessages();
writeConversation();
}
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
For now I'm gonna go to bed since it's midnight here almost so I won't be able to respond to texts immediately
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
Thank you in advance to anyone who decides to help
33 replies
JCHJava Community | Help. Code. Learn.
Created by akuma on 2/10/2025 in #java-help
Error related to arguments in a method
What can be the issue?
33 replies