Hello, I need help!!! Very new to programming.
I need a program that will display a menu with the letters C,E,F,L and X for exit and allow the user to select a letter from the menu. If the user selects X,print an appropriate message and end the program. If the user selects one of the other letters, display letter in a large block

         CCCCCCCCC
         CCCCCCCCC
         CC
         CC
         CC
         CC
         CCCCCCCCC
         CCCCCCCCC 

and then display the menu again. The program should conatin at least 7 methods. The following is what I have so far, but I am stumped how to get the large block output to the user's choice. I am thankful for any help!

import java.util.Scanner;
public class Letters
{

 public static void main(String[] args)
 {
  displayMenu();
  displayMessage();
  printBlockC('C',3,10);
  printBlockC('C',3,3);
  printBlockC('C',3,10);
  }
  public static void displayMenu()
  {
  char letter;
  String input;
  Scanner keyboard=new Scanner (System.in);
  System.out.println("Please enter a letter:\n C, E, F, or L,  \n"+
                     " Enter X to exit");
  input=keyboard.nextLine();
  letter=input.charAt(0);



   while(input.equalsIgnoreCase("C,E,F,L,"))
  {
  System.out.println("Please enter a letter:\n C, E, F,or L, \n"+
                     " Enter X to exit");
  input=keyboard.nextLine();
  letter=input.charAt(0);

  }


} 

public static void displayMessage()
{
System.out.print("Thank you for playing!");
}
public static void printBlockC(char symbol, int rows,int columns)
{
 int i;
int j;
for(i=1;i<=rows;i++)
{
for(j=1;j<=columns;j++)
{
System.out.print(symbol);
}
System.out.println();
}
} 
public static void printBlockE(char symbol, int rows,int columns)
{
 int i;
int j;
for(i=1;i<=rows;i++)
{
for(j=1;j<=columns;j++)
{
System.out.print(symbol);
}
System.out.println();
}
}
public static void printBlockF(char symbol, int rows,int columns)
{
 int i;
int j;
for(i=1;i<=rows;i++)
{
for(j=1;j<=columns;j++)
{
System.out.print(symbol);
}
System.out.println();
}
}
public static void printBlockL(char symbol, int rows,int columns)
{
 int i;
int j;
for(i=1;i<=rows;i++)
{
for(j=1;j<=columns;j++)
{
System.out.print(symbol);
}
System.out.println();
}
}
}
}
jasimp commented: read the reponses to your original thread -2

Recommended Answers

All 3 Replies

It looks like you don't save the input anywhere other than in displayMenu(). None of the other methods can see that input variable.
You could have displayMenu() return the character that the user input and then pass that to a printing method.

It'll look like:

public static String displayMenu(){
//do stuff
return input;
}

Then in your main method you can say:
String input = displayMenu();

Hello, I need help!!! Very new to programming.
I need a program that will display...

You already have a thread dedicated to this same exact question here, with quite a few responses.

Thank you for all of your help!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.