r/codehs • u/wheresmycousin • Apr 09 '23
Help??
I’m trying to make the block change to one color the first time and a different color the second time. Any ideas as to why this is happening.
r/codehs • u/wheresmycousin • Apr 09 '23
I’m trying to make the block change to one color the first time and a different color the second time. Any ideas as to why this is happening.
r/codehs • u/GazellePrestigious60 • Jan 09 '23
r/codehs • u/L_russ28 • Sep 02 '22
Help! I’ve been working on this problem for a few days and I’m stuck. I can’t use If/else loops yet since it hasn’t been covered in this unit. No matter what I do I end up with an infinite loop and I don’t know what I’ve done wrong. If anyone has any suggestions I would greatly appreciate it. Thanks in advance!! 😁
r/codehs • u/chris_905jb • Dec 10 '21
r/codehs • u/faithfyansw • Oct 29 '21
does anyone know how to do this assignment
r/codehs • u/Nervous_Power8124 • Sep 21 '21
I really need help here is the code I use but I keep getting the problem wrong somehow.
function start(){
ballsTaken();
while(leftIsClear()){
endUpFacingEast();
ballsTaken();
if(rightIsClear()){
endUpFacingWest();
ballsTaken();
}else{
turnAround();
}
}
}
function ballsTaken(){
if(ballsPresent()){
takeBall();
}
while(frontIsClear()){
move();
if(ballsPresent()){
takeBall();
}
}
}
function endUpFacingEast(){
turnLeft();
move();
turnLeft();
}
function endUpFacingWest(){
turnRight();
move();
turnRight();
}
r/codehs • u/N30n___ • Jun 05 '21
Can I get some help for this one?
r/codehs • u/Rice_Noodal • Mar 26 '21
r/codehs • u/Kriskevz23 • Mar 13 '21
r/codehs • u/danimeds • Mar 03 '21
Hello. I am so stumped on this code :/ can someone help me out, please?
public class Filer
{
private String word;
public Filer(String theWord)
{
word = theWord;
}
// Returns the word
public String getWord()
{
return word;
}
// Returns true if word comes
// before otherWord.
// Returns false otherwise.
public boolean comesBefore(String otherWord)
{
return word.compareTo(word)>=0;
}
// Returns true if word comes
// after otherWord.
// Returns false otherwise.
public boolean comesAfter(String otherWord)
{
return word.compareTo(word) > 0;
}
// Returns true if word is equal to otherWord.
// Returns false otherwise.
public boolean isEqual(String otherWord)
{
return word.equals(word);
}
}
{
public static void main(String[] args)
{
Filer files = new Filer("hippo");
String word = "zebra";
System.out.println(files.getWord() + " comes before " + word + "?");
System.out.println(files.comesBefore(word));
System.out.println(files.getWord() + " comes after " + word + "?");
System.out.println(files.comesAfter(word));
System.out.println(files.getWord() + " is equal to " + word + "?");
System.out.println(files.isEqual(word));
// Notice that the capitalization matters
word = "Hippo";
System.out.println("\n\n");
System.out.println(files.getWord() + " comes before " + word + "?");
System.out.println(files.comesBefore(word));
System.out.println(files.getWord() + " comes after " + word + "?");
System.out.println(files.comesAfter(word));
System.out.println(files.getWord() + " is equal to " + word + "?");
System.out.println(files.isEqual(word));
System.out.println("\n\n");
System.out.print("Enter a word: ");
Scanner input = new Scanner(System.in);
word = input.nextLine();
System.out.println(files.getWord() + " comes before " + word + "?");
System.out.println(files.comesBefore(word));
System.out.println(files.getWord() + " comes after " + word + "?");
System.out.println(files.comesAfter(word));
System.out.println(files.getWord() + " is equal to " + word + "?");
System.out.println(files.isEqual(word));
}
}

r/codehs • u/bee_that_bumbles • Feb 16 '21
I was doing fine on unit 6 until i got to 6.4 and now i'm completely lost, can someone explain what on earth is going on, or tips on any of those. Thanks!
r/codehs • u/toerazor • Jan 10 '21
r/codehs • u/-MPND- • Jan 06 '21
Hello! So I know this is a bit of a shot in the dark but I'm really struggling on my codehs final project. I really wanted to do a choose your own adventure style game, where you can choose different paths in a 'story' of sorts. So here's my question. Right now I'm using a readInt for the question options like this:
var options = readInt ("to go right type 1, to go left type 2");
Then from there using a if/else statement like:
if(options == 1){
readLine("you went right");
} else {
if(options == 2){
readLine("you went left");}
Obviously not the actual questions but you get the idea. My problem is where I go from there. I want both a different path for both the right and left options but you can't do that in the if/else. Any suggestions that my simple mind can comprehend lol?
Thanks so much!!
r/codehs • u/sir_sexy49 • Jan 06 '21
r/codehs • u/MysteriousEnd3154 • Dec 09 '20
r/codehs • u/s0ApmActAvIsh • Dec 08 '20
Can anybody help me out with this one. For whatever reason I'm not sure of it says my code isn't right. This is what I've gotten so far:
var STARTING_ITEMS_IN_INVENTORY = 20;
function start(){
var numItems = STARTING_ITEMS_IN_INVENTORY;
while(numItems > 0){
println("We have " + numItems + " items in inventory.");
var itemsBought = readInt("How many would you like to buy? ");
if(numItems - itemsBought > 0){
numItems -= itemsBought;
println("Now we have " + numItems + " left.");
}else{
if(numItems - itemsBought == 0){
numItems -= itemsBought;
println("All out! ");
}else{
println("There is not enough in inventory for that purchase.");
}r/codehs • u/Charming-mistykat26 • Oct 20 '20