Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9137301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:05:13+00:00 2026-06-17T09:05:13+00:00

The problem I’m trying to solve is composing a paragraph and when I say

  • 0

The problem I’m trying to solve is composing a paragraph and when I say 1 my program says thumb on the second line of my song. When my program says 2 it should say shoe on my second line of my song. My program is not working as I planned and I’m not sure if I’m using the switch statement correctly inside the for loop or if the sequence of my program is wrong.

import acm.program.*;

public class SingChildSong extends ConsoleProgram {
    public void run() {
        for (int i = 1; i < 3; i++){
            println ("This old man, he played" + i);

            switch (i) {
                case 1: println("thumb"); break;
                case 2: println("shoe"); break;
                case 3: println("knee"); break;
            }

            println ("He played knick-knack on my"  + (i));
            println ("With a knick-knack, paddy-whack");
            println ("Give your dog a bone.");
            println ("This old man came rolling home.");

            println ( "" );
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:05:14+00:00Added an answer on June 17, 2026 at 9:05 am

    If I get it right you are intending to do:

    ...
    for (int i = 1; i <= 3; i++){
        System.out.println ("This old man, he played " + i);
        String word;
    
        switch (i) {
        case 1: word = "thumb"; break;
        case 2: word = "shoe"; break;
        case 3: word = "knee"; break;
        }
    
        System.out.println ("He played knick-knack on my "  + word);
        System.out.println ("With a knick-knack, paddy-whack");
        System.out.println ("Give your dog a bone.");
        System.out.println ("This old man came rolling home.");
    
        System.out.println ( "" );
     }
    ...
    

    As you say Strings are not yet studied in your book, the correct answer, without Strings should be:

    ...
    for (int i = 1; i <= 3; i++){
        System.out.println ("This old man, he played " + i);
    
        switch (i) {
        case 1:
            System.out.println ("He played knick-knack on my thumb");
            break;
        case 2:
            System.out.println ("He played knick-knack on my shoe");
            break;
        case 3: 
            System.out.println ("He played knick-knack on my knee");
            break;
        }
    
        System.out.println ("With a knick-knack, paddy-whack");
        System.out.println ("Give your dog a bone.");
        System.out.println ("This old man came rolling home.");
    
        System.out.println ( "" );
     }
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I am trying to build a recursive tree using a function and data
Problem: I have two array where one produce a category and the second produce
Problem statement I'm trying to implement my own virtual keyboard following example softkeyboard, found
Problem: Write a program that prompts the user to enter some number of 1,
Problem, simple and annoying. Im just trying to print a list of names, collected
Problem I'm trying to build a minimal example where I create a many-to-many relationship
Problem I'm trying to log the data returned from a JSON call, and console.log(jsonData)
Problem : i'm trying to add a 2nd Jpanel in my frame but when
Problem in short: I'm trying to make a simple show/hide toggle work on just
Problem: I'm trying to integrate a slider (carousel) inside an info window of google

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.