loops - Java times table -
I want to try to make this type of output but there are some errors in my code. Would it be best to use the statement, or use another loop?
Here is my desired output: My current code is: Thanks. I'm looking for some problems, the first letter letter
Do you want to continue & gt; & Gt; Please enter an integer & gt; & Gt; 2 table 2 1 x 2 = 2 2 x 2 = 4 ... 12 x 2 = 24 Do you want to continue & gt; & Gt; T
import java.util.Scanner; Public class tugas6 {public static zero main (string [] args) {scanner input = new scanner (System.in); Int Pilihan; Int i, j; System.out.println ("Do you want to continue;;)"; Pillian = input.exit (); If (pilihan == y) System.out.println (Please enter "integer> gt;"); Scanner = new scanner (System.in); J = in.nextInt (); System.out.println ("Table" + J); For (i = 1; i & lt; = 12; i ++) System.out.println (+ i + "*" + + "+" (+ i * j)); Other (pillion == t) System.out.println ("Thanks"); }}}
'' characters Should be surrounded by. Next your
if requires a code block because there are multiple statements in it, you do not need to
in because you have
input So, your code should be something like this,
if (pilihan == 'y') {System.out.println ("Please enter integer>">); J = input.nextInt (); System.out.println ("Table" + J); For (i = 1; i & lt; = 12; i ++) System.out.println (String.valueOf (i) + "*" + + "" "+ (i * j)); } And if (pillion == 't') {System.out.println ("thank you"); }
Comments
Post a Comment