## Featured Replies in this Discussion

- by MoucheI understand it can be difficult, but on this forum we help people that show that they've put in some effort. We do not take your requirements and write a program for you. Please show what you've done and then ask a specific questions such as "Why isn't my function for printing a character array working?". You said you're up to point 13. Which part of point 13 do you not understand? You should have…

I understand it can be difficult, but on this forum we help people that show that they've put in some effort. We do not take your requirements and write a program for you.

Please show what you've done and then ask a specific questions such as "Why isn't my function for printing a character array working?".

You said you're up to point 13. Which part of point 13 do you not understand? You should have the user input section complete from the previous points, so you need write the part that prints each letter of a String.

Here are a few things for you to look into for help in this section:

How do you print to the console/terminal in Java?

What does charAt take as parameters? What does it return?

Ok....first of all, do you really need to answer like that to someone in need? I never asked for instant answer. Of course I would love to know how to do it. All I asked was for help.

And yes, I have done my own work, I have done all that I can, and which is why posting on this forum is my last resort. Don't you have any sympathy towards someone who truly needs help? It's not like I came to this forum to ask for insta- answer...... I simply asked for help.... and it's not like I have not done any work....

Now for those who want to help, here, I did my best.

```
import billboard.BillboardInterface;
import billboard.DigitalBillboardFrame;
import java.util.Scanner;
/**
* Partial solution for Stage 1 of the digital billboard
*
* @author phi
* @version 2011 2
*/
public class DynamicBillboard
{
public static void main(String[] args)
{
// initial size of the display in pixels
final int WINDOW_WIDTH = 300;
final int WINDOW_HEIGHT = 120;
// size of the grid for the digital billboard
final int BB_WIDTH = 50;
final int BB_HEIGHT = 30;
// create a billboard
BillboardInterface billboard = new DigitalBillboardFrame(
"SCSS",
WINDOW_WIDTH, WINDOW_HEIGHT,
BB_WIDTH, BB_HEIGHT);
// we will make letters 5 cells wide and 12 high
final int LETTER_WIDTH = 5;
final int LETTER_HEIGHT = 12;
// and leave a 1 cell gap between letters
final int GAP = 1;
// the top left of the first letter in the word will be 2 cells from the left and 1 down
final int START_X = 2;
final int START_Y = 1;
Scanner Keyboard = new Scanner (System.in);
String userMsg ="";
// forever
for(;;)
{
System.out.println("Please enter a message: ");
userMsg = Keyboard.nextLine();
String v = "";
String result = v.trim();
// get a message from the user
// for each letter in the message
int x = START_X;
int y = START_Y;
for(int i = 0; i < 5; i++)
{
// display the i_th letter
switch (5)
{
case 's':
billboard.turnOn(START_X+1, START_Y+2);
billboard.turnOn(START_X+2, START_Y+2);
billboard.turnOn(START_X+3, START_Y+2);
billboard.turnOn(START_X+4, START_Y+2);
billboard.turnOn(START_X, START_Y+3);
billboard.turnOn(START_X, START_Y+4);
billboard.turnOn(START_X+1, START_Y+5);
billboard.turnOn(START_X+2, START_Y+5);
billboard.turnOn(START_X+3, START_Y+5);
billboard.turnOn(START_X+4, START_Y+6);
billboard.turnOn(START_X+4, START_Y+7);
billboard.turnOn(START_X, START_Y+8);
billboard.turnOn(START_X+1, START_Y+8);
billboard.turnOn(START_X+2, START_Y+8);
billboard.turnOn(START_X+3, START_Y+8);
break;
final int START_X1 = 8;
final int START_Y1 = 1;
case 'p':
billboard.turnOn(START_X1, START_Y1+2);
billboard.turnOn(START_X1+1, START_Y1+2);
billboard.turnOn(START_X1+2, START_Y1+2);
billboard.turnOn(START_X1+3, START_Y1+2);
billboard.turnOn(START_X1, START_Y1+3);
billboard.turnOn(START_X1, START_Y1+4);
billboard.turnOn(START_X1, START_Y1+5);
billboard.turnOn(START_X1, START_Y1+6);
billboard.turnOn(START_X1, START_Y1+7);
billboard.turnOn(START_X1, START_Y1+8);
billboard.turnOn(START_X1, START_Y1+9);
billboard.turnOn(START_X1, START_Y1+10);
billboard.turnOn(START_X1, START_Y1+11);
billboard.turnOn(START_X1+1, START_Y1+8);
billboard.turnOn(START_X1+2, START_Y1+8);
billboard.turnOn(START_X1+3, START_Y1+8);
billboard.turnOn(START_X1+4, START_Y1+3);
billboard.turnOn(START_X1+4, START_Y1+4);
billboard.turnOn(START_X1+4, START_Y1+5);
billboard.turnOn(START_X1+4, START_Y1+6);
billboard.turnOn(START_X1+4, START_Y1+7);
break;
final int START_X2 = 14;
final int START_Y2 = 1;
case 'a':
billboard.turnOn(START_X2, START_Y2+3);
billboard.turnOn(START_X2, START_Y2+4);
billboard.turnOn(START_X2, START_Y2+5);
billboard.turnOn(START_X2, START_Y2+6);
billboard.turnOn(START_X2, START_Y2+7);
billboard.turnOn(START_X2+1, START_Y2+2);
billboard.turnOn(START_X2+1, START_Y2+8);
billboard.turnOn(START_X2+2, START_Y2+2);
billboard.turnOn(START_X2+2, START_Y2+8);
billboard.turnOn(START_X2+3, START_Y2+2);
billboard.turnOn(START_X2+3, START_Y2+3);
billboard.turnOn(START_X2+3, START_Y2+4);
billboard.turnOn(START_X2+3, START_Y2+5);
billboard.turnOn(START_X2+3, START_Y2+6);
billboard.turnOn(START_X2+3, START_Y2+7);
billboard.turnOn(START_X2+4, START_Y2+8);
break;
final int START_X3 = 20;
final int START_Y3 = 1;
case 'r':
billboard.turnOn(START_X3, START_Y3+2);
billboard.turnOn(START_X3+1, START_Y3+3);
billboard.turnOn(START_X3+1, START_Y3+4);
billboard.turnOn(START_X3+1, START_Y3+5);
billboard.turnOn(START_X3+1, START_Y3+6);
billboard.turnOn(START_X3+1, START_Y3+7);
billboard.turnOn(START_X3+1, START_Y3+8);
billboard.turnOn(START_X3+2, START_Y2+2);
billboard.turnOn(START_X3+3, START_Y2+2);
billboard.turnOn(START_X3+4, START_Y2+3);
break;
final int START_X4 = 26;
final int START_Y4 = 1;
case 'e':
billboard.turnOn(START_X4, START_Y4+3);
billboard.turnOn(START_X4, START_Y4+4);
billboard.turnOn(START_X4, START_Y4+5);
billboard.turnOn(START_X4, START_Y4+6);
billboard.turnOn(START_X4, START_Y4+7);
billboard.turnOn(START_X4+1, START_Y4+2);
billboard.turnOn(START_X4+1, START_Y4+5);
billboard.turnOn(START_X4+1, START_Y4+8);
billboard.turnOn(START_X4+2, START_Y4+2);
billboard.turnOn(START_X4+2, START_Y4+5);
billboard.turnOn(START_X4+2, START_Y4+8);
billboard.turnOn(START_X4+3, START_Y4+2);
billboard.turnOn(START_X4+3, START_Y4+5);
billboard.turnOn(START_X4+3, START_Y4+8);
billboard.turnOn(START_X4+4, START_Y4+3);
billboard.turnOn(START_X4+4, START_Y4+4);
billboard.turnOn(START_X4+4, START_Y4+7);
break;
default:
x += LETTER_WIDTH + GAP;
}
// display the letter
}
}
}
}
```

You hadn't shown any proof that you had done anything. Were you assuming we'd just post the solution? Anyways, now that we have the code, we're one step closer.

What part of point 13 do you not understand? You haven't used charAt anywhere in your code. Make an attempt at what it asks you to do with the functions it gives you, and then show us what you've done and ask a question about it.

```
import java.util.Scanner;
import billboard.BillboardInterface;
import billboard.DigitalBillboardFrame;
import javax.swing.JOptionPane;
/**
* Partial solution for Stage 2 of the digital billboard
*
* @author phi
* @version 2011 2
*/
public class style
{
public static void main(String[] args)
{
// initial size of the display in pixels
final int WINDOW_WIDTH = 300;
final int WINDOW_HEIGHT = 120;
// size of the grid for the digital billboard
final int BB_WIDTH = 50;
final int BB_HEIGHT = 30;
// create a billboard
BillboardInterface billboard = new DigitalBillboardFrame(
"SCSS",
WINDOW_WIDTH, WINDOW_HEIGHT,
BB_WIDTH, BB_HEIGHT);
// we will make letters 5 cells wide and 12 high
final int LETTER_WIDTH = 5;
final int LETTER_HEIGHT = 12;
// and leave a 1 cell gap between letters
final int GAP = 1;
// the top left of the first letter in the word will be 2 cells from the left and 1 down
final int START_X = 2;
final int START_Y = 1;
final boolean isJOptionPaneUsed = true; //for Scanner (0) or JOptionPane (1);
String inputString; // input string recved
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// first make sure the display is blank
billboard.allOff();
// forever
for(;;)
{
if (isJOptionPaneUsed)
{
//get a message from the user
// Get user input
inputString = JOptionPane.showInputDialog("Enter a 5 letter word made up of the letters 's', 'p', 'a', 'r' and 'e' ");
}
else
{
keyboard = new Scanner(System.in);
System.out.println("\nEnter a 5 letter word made up of the letters 's', 'p', 'a', 'r' and 'e' ");
String input = keyboard.nextLine();
}
//for each letter in the message
int x = START_X; // keep track of where each letter should go
int y = START_Y;
for(int i = 0; i < 6 ; i++)
{
// display the i_th letter
final int START_X1 = 8;
final int START_Y1 = 1;
final int START_X2 = 14;
final int START_Y2 = 1;
final int START_X3 = 20;
final int START_Y3 = 1;
final int START_X4 = 26;
final int START_Y4 = 1;
switch((inputString).charAt(0))
{
case 's':
billboard.turnOn(START_X+1, START_Y+2);
billboard.turnOn(START_X+2, START_Y+2);
billboard.turnOn(START_X+3, START_Y+2);
billboard.turnOn(START_X+4, START_Y+2);
billboard.turnOn(START_X, START_Y+3);
billboard.turnOn(START_X, START_Y+4);
billboard.turnOn(START_X+1, START_Y+5);
billboard.turnOn(START_X+2, START_Y+5);
billboard.turnOn(START_X+3, START_Y+5);
billboard.turnOn(START_X+4, START_Y+6);
billboard.turnOn(START_X+4, START_Y+7);
billboard.turnOn(START_X, START_Y+8);
billboard.turnOn(START_X+1, START_Y+8);
billboard.turnOn(START_X+2, START_Y+8);
billboard.turnOn(START_X+3, START_Y+8);
break;
case 'p':
billboard.turnOn(START_X1, START_Y1+2);
billboard.turnOn(START_X1+1, START_Y1+2);
billboard.turnOn(START_X1+2, START_Y1+2);
billboard.turnOn(START_X1+3, START_Y1+2);
billboard.turnOn(START_X1, START_Y1+3);
billboard.turnOn(START_X1, START_Y1+4);
billboard.turnOn(START_X1, START_Y1+5);
billboard.turnOn(START_X1, START_Y1+6);
billboard.turnOn(START_X1, START_Y1+7);
billboard.turnOn(START_X1, START_Y1+8);
billboard.turnOn(START_X1, START_Y1+9);
billboard.turnOn(START_X1, START_Y1+10);
billboard.turnOn(START_X1, START_Y1+11);
billboard.turnOn(START_X1+1, START_Y1+8);
billboard.turnOn(START_X1+2, START_Y1+8);
billboard.turnOn(START_X1+3, START_Y1+8);
billboard.turnOn(START_X1+4, START_Y1+3);
billboard.turnOn(START_X1+4, START_Y1+4);
billboard.turnOn(START_X1+4, START_Y1+5);
billboard.turnOn(START_X1+4, START_Y1+6);
billboard.turnOn(START_X1+4, START_Y1+7);
x += LETTER_WIDTH + GAP;
break;
case 'a':
billboard.turnOn(START_X2, START_Y2+3);
billboard.turnOn(START_X2, START_Y2+4);
billboard.turnOn(START_X2, START_Y2+5);
billboard.turnOn(START_X2, START_Y2+6);
billboard.turnOn(START_X2, START_Y2+7);
billboard.turnOn(START_X2+1, START_Y2+2);
billboard.turnOn(START_X2+1, START_Y2+8);
billboard.turnOn(START_X2+2, START_Y2+2);
billboard.turnOn(START_X2+2, START_Y2+8);
billboard.turnOn(START_X2+3, START_Y2+2);
billboard.turnOn(START_X2+3, START_Y2+3);
billboard.turnOn(START_X2+3, START_Y2+4);
billboard.turnOn(START_X2+3, START_Y2+5);
billboard.turnOn(START_X2+3, START_Y2+6);
billboard.turnOn(START_X2+3, START_Y2+7);
billboard.turnOn(START_X2+4, START_Y2+8);
break;
case 'r':
billboard.turnOn(START_X3, START_Y3+2);
billboard.turnOn(START_X3+1, START_Y3+3);
billboard.turnOn(START_X3+1, START_Y3+4);
billboard.turnOn(START_X3+1, START_Y3+5);
billboard.turnOn(START_X3+1, START_Y3+6);
billboard.turnOn(START_X3+1, START_Y3+7);
billboard.turnOn(START_X3+1, START_Y3+8);
billboard.turnOn(START_X3+2, START_Y2+2);
billboard.turnOn(START_X3+3, START_Y2+2);
billboard.turnOn(START_X3+4, START_Y2+3);
break;
case 'e':
billboard.turnOn(START_X4, START_Y4+3);
billboard.turnOn(START_X4, START_Y4+4);
billboard.turnOn(START_X4, START_Y4+5);
billboard.turnOn(START_X4, START_Y4+6);
billboard.turnOn(START_X4, START_Y4+7);
billboard.turnOn(START_X4+1, START_Y4+2);
billboard.turnOn(START_X4+1, START_Y4+5);
billboard.turnOn(START_X4+1, START_Y4+8);
billboard.turnOn(START_X4+2, START_Y4+2);
billboard.turnOn(START_X4+2, START_Y4+5);
billboard.turnOn(START_X4+2, START_Y4+8);
billboard.turnOn(START_X4+3, START_Y4+2);
billboard.turnOn(START_X4+3, START_Y4+5);
billboard.turnOn(START_X4+3, START_Y4+8);
billboard.turnOn(START_X4+4, START_Y4+3);
billboard.turnOn(START_X4+4, START_Y4+4);
billboard.turnOn(START_X4+4, START_Y4+7);
break;
default:
}
x += LETTER_WIDTH + GAP;
// display the letter
}
// OK - ready to update the display
billboard.redisplay(0);
}
}
}
```

Not too useful posting code to use for testing if there are missing packages: billboard

Can you post the console contents showing your input and the programs output?

To copy the contents of the command prompt window:

Click on Icon in upper left corner

Select Edit

Select 'Select All' - The selection will show

Click in upper left again

Select Edit and click 'Copy'

Paste here.

eddieteddie, it sounds like you're not familiar with functions. If you're in school, I'm guessing you have a book. Review functions and specifically String functions if your book has them.

Instead of just guessing where to put something, think about what you are trying to do. The assignment starts with pseudocode and has you fill in parts slowly with blocks of code so you can understand logically you need to do.

You are storing the user input into the String userMsg. Point 12 explains that you need to use a for loop to display each letter in order. This means that each time through the loop, you should display one letter on the console.

First, figure out how to display a letter on the console. Next, figure out how to use charAt to retrieve one letter from a string. Finally, put those concepts together, and have the code in the loop print the i_th letter in the String.

Hopefully that helps. Try something and post your results.

not sure how to post the outputs. but when i run the program the question box pops up and asks me "Enter a 5 letter word made up of the letters 's', 'p', 'a', 'r' and 'e' " and it will keep asking me. however when i enter a word "spear" for example only the S would display on the billboard, or when i spell "pears" only P would display and they would display in the same spot the S P would appear if i wrote SPARE.

The "i_th character" is a phrase to mean a character at position i in a string. Instead of giving it a number like the 4th character, you make it more general. If you use a loop to print out a string, you can do it one character at a time by having the loop go from i = 0 to i = strlen(your_string) and print your_string* each iteration.*