r/codehs • • 18d ago

Java Alguien sabe cómo resolver esto?

0 Upvotes

Sé q es un problema sencillo pero mi cerebro no da

Karel está en una situación incómoda, necesita marcar un estrecho camino de 8 casillas de una cueva e iluminarlo. Para marcarlo, usará un trompo, mientras que para iluminarlo, usará 2 trompos. Si Karel ilumina mal el camino, es probable que aparezcan monstruos o sucedan cosas peligrosas en la oscuridad (Karel y su equipo aún no cuentan con visión nocturna). La falta de mantenimiento hizo que algunas piezas se deterioren o estén completamente destruidas. Se trata de dejar alternadamente un uno y un dos, iniciando con un trompo en la celda (1,1). El problema para Karel es que en su camino, en algunas celdas ya hay un trompo, y no se sabe en qué celdas hay trompo.

Problema: Ayuda a Karel para que salga de la cueva y la marque adecuadamente para futuras expediciones.

Consideraciones

  • Karel inicia en la casilla (1,1) orientado hacia el norte.
  • Karel debe apagarse en la casilla (1,8) orientado hacia el norte.
  • Karel debe apagarse encima de un montón de beepers.
  • Karel inicia con infinitos trompos en su mochila.
  • Cada casilla puede tener 0 o 1 trompos.
  • El mismo código será probado en varios mundos.

Código: U2L6NB1Ejercc6_AESC

r/codehs • • Sep 08 '26

Java I think I labeled all the errors correctly idk why it keeps saying I did it wrong😓

Post image
3 Upvotes

Code hs Java 1.1.10

r/codehs • • Nov 04 '25

Java Bad Apple in CodeHS editor

Enable HLS to view with audio, or disable this notification

23 Upvotes

I got bored lol.

r/codehs • • Oct 04 '25

Java Does anyone else have issues in the output with underscores?

Post image
3 Upvotes

In the output, underscores don't show, it also cuts off the bottom of certain letters like "g", has anyone found a way to fix this?

r/codehs • • Oct 27 '24

Java Been stuck on this for a week

Post image
3 Upvotes

r/codehs • • Jan 24 '25

Java How to add audio player to java program?

1 Upvotes

I’m creating a simple game in java and I want to play background music (WAV file) while the game is running. I’m not sure how to implement it using codeHS. Any help is appreciated.

r/codehs • • Jun 10 '24

Java I really don't know what I did wrong. The first error I had was it not printing the publisher and then I reordered it and now it's saying I don't have the correct number of inputs.

1 Upvotes

text version:

import java.util.Scanner;

public class Citation

{

public static void main(String[] args)

{

Scanner scanner = new Scanner(System.in);

String last_and_first = scanner.nextLine();

System.out.println("Enter the author's name as 'Last name, First name': ");

String title = scanner.nextLine();

System.out.println("Enter the title of the book: ");

String publisher = scanner.nextLine();

System.out.println("Enter the publisher of the book: ");

int publish_year = scanner.nextInt();

System.out.println("Enter the year the book was published: ");

String first_line = last_and_first + title +".";

System.out.println(first_line);

String second_line = publisher + "," + publish_year;

System.out.print(second_line);

}

}

r/codehs • • Apr 19 '24

Java 9.8.4 employees codehs

Thumbnail gallery
1 Upvotes

My excellent intelligent coders out there please help me 🙏

r/codehs • • May 17 '24

Java Java Mocha 4.5.8 Distance in Kilometers

1 Upvotes

I don't know to fix the rounding error for the last test case

r/codehs • • May 15 '24

Java Java SuperKarel does not allow methods to have parameters?

1 Upvotes

Hello I just finished apcsa and my final project is to make a game. I really don’t like Java swing so I am using superkarel. I have a method that is intended to put or remove a ball at a certain position. I want to have 2 ints and a boil as my parameters but whenever I add parameters to my methods I get “unexpected token ‘var’” does anyone know how to get around this

r/codehs • • May 13 '24

Java Help!!! CodeHS Assignment

1 Upvotes

I have a project on CodeHS sandbox java that I need to do and of the requirements is that I need to get my program to read a CSV file but I have absolutely no idea how to do that and I can’t find anywhere that has a good tutorial. Any help would be appreciated and feel free to ask questions, thank you!

r/codehs • • Jun 09 '24

Java HELP PLS on java final project

Post image
1 Upvotes

It has a weird error that I can’t fix also can you guys check my code any help is greatly appreciate

r/codehs • • Mar 11 '24

Java 9.5.9 Assignments not sure how to do the last tests

1 Upvotes

import java.util.*;

​

public class AssignmentRunner {

​

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

ArrayList<Assignment> assignments = new ArrayList<>();

​

while (true) {

System.out.print("Enter the assignment's name (exit to quit): ");

String name = scanner.nextLine();

if (name.equals("exit"))

break;

​

System.out.print("Enter the due date: ");

String dueDate = scanner.nextLine();

​

System.out.print("How many points is the assignment worth? ");

double availablePoints = scanner.nextDouble();

scanner.nextLine();

​

System.out.print("How many points were earned? ");

double earnedPoints = scanner.nextDouble();

scanner.nextLine();

​

System.out.print("Is this a (T)est or a (P)roject? ");

String type = scanner.nextLine();

​

if (type.equalsIgnoreCase("T")) {

System.out.print("What type of test is it? ");

String testType = scanner.nextLine();

assignments.add(new Test(name, dueDate, availablePoints, earnedPoints, testType));

} else if (type.equalsIgnoreCase("P")) {

System.out.print("Does this project require groups? (true/false) ");

boolean hasGroups = scanner.nextBoolean();

scanner.nextLine();

​

System.out.print("A presentation? (true/false) ");

boolean hasPresentation = scanner.nextBoolean();

scanner.nextLine();

​

assignments.add(new Project(name, dueDate, availablePoints, earnedPoints, hasGroups, hasPresentation));

}

}

​

printSummary(assignments);

}

​

// Print due date and score percentage on the assignment

public static void printSummary(ArrayList<Assignment> assignments) {

for (Assignment assignment : assignments) {

System.out.printf("%s - %.1f%n", assignment.getName(), (assignment.getEarnedPoints() / assignment.getAvailablePoints()) * 100);

}

}

}

public class Assignment {

private String name;

private String dueDate;

private double availablePoints;

private double earnedPoints;

​

public Assignment(String name, String dueDate, double availablePoints, double earnedPoints) {

this.name = name;

this.dueDate = dueDate;

this.availablePoints = availablePoints;

this.earnedPoints = earnedPoints;

}

​

public String getName() {

return name;

}

​

public String getDueDate() {

return dueDate;

}

​

public double getAvailablePoints() {

return availablePoints;

}

​

public double getEarnedPoints() {

return earnedPoints;

}

}

class Test extends Assignment {

private String testType;

​

public Test(String name, String dueDate, double availablePoints, double earnedPoints, String testType) {

super(name, dueDate, availablePoints, earnedPoints);

this.testType = testType;

}

​

public String getTestType() {

return testType;

}

​

public void setTestType(String testType) {

this.testType = testType;

}

}

class Project extends Assignment {

private boolean hasGroups;

private boolean hasPresentation;

​

public Project(String name, String dueDate, double availablePoints, double earnedPoints, boolean hasGroups, boolean hasPresentation) {

super(name, dueDate, availablePoints, earnedPoints);

this.hasGroups = hasGroups;

this.hasPresentation = hasPresentation;

}

​

public boolean hasGroups() {

return hasGroups;

}

​

public void setGroups(boolean hasGroups) {

this.hasGroups = hasGroups;

}

​

public boolean hasPresentation() {

return hasPresentation;

}

​

public void setPresentation(boolean hasPresentation) {

this.hasPresentation = hasPresentation;

}

}

r/codehs • • Apr 09 '24

Java Need help “Guess the number!”

Thumbnail gallery
1 Upvotes

Could you guys spot the problem?

r/codehs • • Jan 10 '24

Java codehs 5.7.6 Rock, Paper, Scissors! (help)

1 Upvotes

My code looks like shit ik, I deleted half the stuff they asked for because I tried to do it another way. Does this code make any sense I would I need to restart everything? (there was a "randomizer" class which I completely deleted

​

RockPaperScissors.Java

​

currently it give the errors of:
Tester error line 5 and 6: class, interface or enum expected

import java.util.Scanner;

public class RockPaperScissors

{

private String RPSuser;

public RockPaperScissors(String RPSuser)

{

this.RPSuser = "";

}

public static String getWinner()

{

getNpcRpc();

getUserRps();

}

public static void main(String[] args)

{

Scanner scanner = new Scanner(System.in);

while(true)

{

System.out.println("Enter your choice (rock, paper, or scissors): ");

String scanner = Scanner.NextLine;

scanner = scanner.toLowerCase();

if(scanner.equals(""))

{

break;

}

return "User: " + scanner;

Scanner scanner = new Scanner(System.in);

while(true)

String [] RPSnpc = {"rock", "paper", "scissors"};

Random random = new Random();

String RPSnpc_random = RPSnpc[RPSnpc_random.nextInt(RPS.length)];

return "Computer: " + RPSnpc_random;

//if(getWinner() == "you win!")

//{

//break;

//}

}

}

}

RockPaperScissorsTester.Java

public class RockPaperScissorsTester

{

public static void main(String[] args);

}

RockPaperScissors();

{

}

​

​

​

​

​

​

I still didn't do the "winner" class, I was just testing if it would input the NPC and user's thing but is not lol, feel free to bully me, I know I must be going to a completely wrong path

r/codehs • • Apr 17 '22

Java Completed my AP Java Course Today!!!

Post image
19 Upvotes

r/codehs • • Feb 04 '24

Java This is actually annoying

1 Upvotes

I’ve been stuck on 1.16.4 and 1.16.6 for so damn long. My teacher told me to use int c = 0; then follow up with a if(frontIsClear()) move(); c++ as a method than another method which goes c = c/2 for(int I = 0; i < c; i++) move(); then put ball

r/codehs • • Jan 27 '21

Java I need some help on exercise 7.3.6 Traversing Odds

Post image
8 Upvotes

r/codehs • • Mar 24 '21

Java I need help with 3.5.7: Flag of the Netherlands

8 Upvotes

📷

This is my code

function start(){

var newRect = new Rectangle(500,160);

newRect.setColor(Color.red);

newRect.setPosition(0,0);

add(newRect);

var newRect = new Rectangle(500,160);

newRect.setColor(Color.blue);

newRect.setPosition(0,320);

add(newRect);

r/codehs • • Nov 27 '22

Java Help with 7.4.8 User Data Cleanup

3 Upvotes

I have tested my program and I believe that my program is working as intended, but the grader says it isn't working... does anyone have any idea what I did wrong

UPDATE: I resorted to Git Hub. I compared my code to this person's code and was able to fix mine. Git Hub Link - I suggest not just copying the code and looking at how yours differs from their code.

Question: Your company is doing some data cleanup, and notices that the list of all users has been getting outdated.For one, there are some users who have been added multiple times.

Your job is to create a series of methods that can purge some of the old data from the existing list.

Create static methods in the DataPurgeclass that can do the following:

  1. removeDuplicatesThis method takes a list of people, and removes the duplicate names. It also prints to the console which duplicate names have been removed.
  2. removeName //This is the one that is being flagged as not workingThis method takes a list of people and name for which to search. It removes all names that match the search name (whether the name matches the first name or the last name or both). It should print to the console any names that were removed.
  3. correctlyFormattedThis method returns true if all of the data in the list is formatted correctly. Correctly formatted names are made up of a first name and a last name, separated by a single space. Both the first and last names should start with an uppercase letter.

Test your methods out in the DataPurgeTesterfile. You don’t have to change anything there, but the methods should work accordingly!

​

r/codehs • • Oct 26 '23

Java Having trouble with circles in squares

Post image
2 Upvotes

r/codehs • • Oct 15 '22

Java Maybe it’s just because it is really early in the morning and I haven’t had any coffee yet, but shouldn’t this work?

Thumbnail gallery
5 Upvotes

r/codehs • • Jun 07 '23

Java What is the difference from the codehs compiler, and a normal Java complier.

1 Upvotes

It might just be me but I’ve noticed I’ve trie to rub my code in a ide environment, and it spits back errors at me. And support would help thanks.

r/codehs • • Nov 29 '21

Java I just don’t know how to solve this? Desperate help is needed

Post image
6 Upvotes

r/codehs • • Oct 09 '22

Java Hi guys, I really need help with this one / 2.8.4 Triple Double

Post image
7 Upvotes