0

The answers are coming out correctly. They are just not separated by columns. I need them to be in different columns by numbers, multiples of 2, and multiples of 10.

    String head1 = "Number: ";
    String head2 = "Multiplied by 2: ";
    String head3 = "Multiplied by 10:  ";               
    int numberCounter;  // Numbers 0 through 10.
    int byTen;      // Stores the number multiplied by 10.
    int byTwo;          // Stores the number multiplied by 2.
    final int NUM_LOOPS = 10; // Constant used to control loop.

            // This is the work done in the housekeeping() method
    System.out.println("0 through 10 multiplied by 2 and by 10" + "\n");

    // This is the work done in the detailLoop() method
            System.out.print(head1);

            System.out.print(head2);

            System.out.print(head3 + "\n");



    // Initialize loop control variable.
    numberCounter = 0;
            while(numberCounter <= NUM_LOOPS){

                System.out.println(numberCounter);

                byTwo = numberCounter * 2;
                System.out.println(byTwo);

                byTen = numberCounter * 10;
                System.out.println(byTen);

                numberCounter++;
            }
    // Write your counter controlled while loop here
    // This is the work done in the endOfJob() method
            System.exit(0);
} // End of main() method.
Anton Kazakov
  • 2,740
  • 3
  • 23
  • 34
MJ Ngo
  • 1
  • 2
    if you want to draw/format a table via `System.out`, you should also add correct number of spaces to whatever you're printing (by using appropriate formatter, for example). They will not automatically align if you don't tell them how. – M. Prokhorov Jul 04 '17 at 16:51
  • An easy way is to use "print()" method for first two columns and "println()" for the third. Use also a separator like a tab space or a comma. For example: "String sep = '\t'; System.out.print(numberCounter+sep); System.out.print(byTwo+sep); System.out.println(byTen);" – Luca Montagnoli Jul 04 '17 at 16:58

0 Answers0