codehs 5.9.4 answers - Inventory - (5.9.4) 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 (itemsBought <= numItems) { numItems -= itemsBought; println("Now we have " + numItems ); } else { codehs 5.9.4 answers How to use it? codehs 5.9.4 answers println("There is not enough in inventory for that purchase."); } } println("All Out!" ); } ----------------------------------------------------------------------------------------------------------------- - Concentric Circles - (5.9.6) var x = getWidth()/2; var y = getHeight()/2; var RADIUS = 200; codehs 5.9.4 answers PasteShr codehs 5.9.4 answers function start() { var circle = new Circle(RADIUS); circle.setPosition(x,y); circle.setColor(Color.red); add(circle); while(RADIUS > 0){ RADIUS -= 40; circle = new Circle(RADIUS); circle.setPosition(x,y); circle.setColor(Color.black); codehs 5.9.4 answers How to get it for free? codehs 5.9.4 answers add(circle); RADIUS -= 60; circle = new Circle(RADIUS); circle.setPosition(x,y); circle.setColor(Color.red); add(circle); RADIUS -= 40; circle = new Circle(RADIUS); codehs 5.9.4 answers PasteShr codehs 5.9.4 answers circle.setPosition(x,y); circle.setColor(Color.black); add(circle); RADIUS -= -60; circle = new Circle(RADIUS); circle.setPosition(x,y); circle.setColor(Color.red); add(circle); RADIUS -= -20; codehs 5.9.4 answers How to dowload it? codehs 5.9.4 answers circle = new Circle(RADIUS); circle.setPosition(x,y); circle.setColor(Color.red); add(circle); } } ------------------------------------------------------------------------------ 5.10.4 Snake Eyes codehs 5.9.4 answers How to dowload it? codehs 5.9.4 answers function start(){ var numRolls = 0; while (true) { numRolls++; var rollOne = Randomizer.nextInt (1,6); var rollTwo = Randomizer.nextInt (1,6); println ("Rolled: " + rollOne + "," + rollTwo); if (rollOne == 1 && rollTwo == 1) { codehs 5.9.4 answers How to get it? codehs 5.9.4 answers break; } } println ("It took you " + numRolls + " rolls to get snake eyes. "); } - 5.10.5 - Better Password Prompt - codehs 5.9.4 answers PasteShr codehs 5.9.4 answers var SECRET = "abc123"; function start(){ var password = SECRET; while (true) { var potential = readLine ("What is le password "); if(potential == password) { println("You got it!"); break; codehs 5.9.4 answers How to use it? codehs 5.9.4 answers }else{ println("your answer is incorrect "); } } } -------------------------------------------------------- codehs 5.9.4 answers