-1

I am new to Java and can't figure out how to format my code like this: Font “Courier New” Font size “9” Bold

I am trying to format the text of the whole paragraph. I would really appreciate the help. Thanks in advance!

Below is my code:

public class H_1

{
    //--------------------------------------------------------------------
    // main
    //--------------------------------------------------------------------

public static void main (String[] args)
    {

    Graphics
        // Declare variables
        // int someInt;
        // double someReal;
        // String someString;
        Scanner keyboard = new Scanner(System.in);  // Connect to keyboard

        // Show application header
        System.out.println("Welcome to my Application!");

        System.out.println("--------------------------\n");

        // Display output
        System.out.println("I'm singing in the rain");
        System.out.println("Just singing in the rain");
        System.out.println("What a glorious feelin'");
        System.out.println("I'm happy again \n");
        System.out.println("I'm laughing at clouds");
        System.out.println("So dark up above");
        System.out.println("The sun's in my heart");
        System.out.println("And I'm ready for love \n");
        System.out.println("I walk down the lane");
        System.out.println("With a happy refrain");
        System.out.println("Just singin',");
        System.out.println("Singin' in the rain");

        // keyboard.nextInt() reads token from keyboard and converts to whole number
        // keyboard.nextDouble() reads token from keyboard and converts to real number
        // keyboard.next() reads token from keyboard
        // keyboard.nextLine() reads line from keyboard through end-of-line character

        // Close keyboard
        keyboard.close();

        // Show application close
        System.out.println("\nEnd of my Application");

    } 
 }
Emma
  • 1
  • 1

1 Answers1

1

Your question is unclear, but as there aren't too many options to answer, lets go:

  1. If you are really asking how to format your source code; then you have to turn to the preferences of your editor/IDE that you are using. Any meaningful tool will allow you to change the font/size/family of source code.
  2. If you are asking how to "format" something that your java programming is printing; that is a very much different story. And in essence: the java console just prints text; and without using special libraries, you can't do any formatting there.

Edit; as you are focusing on "print out": your code is writing to the console. That means that you are limited in your options. So: consult that link and see if something is there that helps.

Finally: if this is about creating a paper print for your assignment - consider copying the output of your java program into your favorite "office" program to format it there before printing.

Community
  • 1
  • 1
GhostCat
  • 137,827
  • 25
  • 176
  • 248