{"id":"code-hs-java-explain-average-bug","audience":"high-school","category":"coding","track":"coding","technique":"constraints","title":"Get 3 clues about a buggy average without the answer","free":false,"task":"Your intro Java program printed 'Average: 60' when you expected about 78.75, and you want to fix it yourself. Ask for exactly 3 numbered lines, each under 25 words: one per bug you'll need to hunt for, plus a last line telling you which line of code to test first. No code blocks and no corrected code anywhere, with under 100 words in total.","materialLabel":"Your program and its output (attached to your prompt automatically)","material":"// Scores.java  - Unit 4 practice, Mr. Alvarez's Intro to CS\n\npublic class Scores {\n    public static void main(String[] args) {\n        int[] scores = {72, 88, 95, 60};\n        int total = 0;\n\n        for (int i = 1; i < scores.length; i++) {\n            total += scores[i];\n        }\n\n        System.out.println(\"Average: \" + total / scores.length);\n    }\n}\n\n// What I ran:\n//   javac Scores.java\n//   java Scores\n//\n// What it printed:\n//   Average: 60\n//\n// What I expected: (72 + 88 + 95 + 60) / 4 = 315 / 4 = 78.75\n//\n// My guess: maybe the array is wrong?? I checked and it has 4 numbers.\n// I also tried changing println to print and it didn't help.\n// Practice is due Thursday, we go over it in class Friday.","rules":[{"type":"numberedItems","count":3},{"type":"codeBlocks","count":0},{"type":"maxProseWords","max":100}],"mistakes":[{"title":"Getting the fixed program","why":"The AI's default is to hand you corrected code, which skips the part where you learn to debug.","fix":"Say: \"Don't give me corrected code, just point me at the bugs.\"","checks":["r2","codeBlocks"]},{"title":"A long lecture","why":"The AI explains loops, arrays and data types from scratch.","fix":"Add: \"Exactly 3 numbered lines, each under 25 words.\"","checks":["numberedItems","maxProseWords"]},{"title":"Only one bug found","why":"The AI may stop after the first bug, but there are two reasons the number is low.","fix":"Add: \"There may be more than one bug; one line per bug.\"","checks":["r0","r1"]}],"promptHints":[{"label":"Asks for clues, not the fix","patterns":["don'?t (give|write|show).{0,20}(code|fix|answer)","no (corrected|fixed) code","hint","clue","myself"]},{"label":"Sets the number of lines","patterns":["\\b(3|three)\\b.{0,20}(line|point|hint)","numbered"]},{"label":"Caps each line","patterns":["\\d+\\s*words","short"]},{"label":"Says there may be more than one bug","patterns":["more than one","both","each bug","every bug"]},{"label":"Gives the expected result","patterns":["78\\.75","expected"]}],"hint":"You want help finding the bugs, not someone else's fix. Tell the AI that, and how short and how many clues you want.","rubricLabels":["One line points out that the loop starts at i = 1, so the first score (72) is never added","One line points out that int divided by int drops the decimal part (so 243 / 4 gives 60, not 60.75)","Does not give the corrected code or the fixed line (no 'change it to i = 0' with the new code, no rewritten println), and the last numbered line names one line of code to test first"]}