java - How do you print out the division calculated for each pair of variables on the same line? -


updated

I am trying to create a grid that shows the variable numOne and num2 two Aliquot or not together. Basically, I want to see the result like this

  1 2 3 4 .... 1 tresult tResult tResult tResult .... 2 tRsult tResult tResult tResult .... 3 tRsult TResult tResult TResult .... 4 tRsult tResult tResult tResult .... 5 tResult tResult tResult tResult .....  

tResult (x% y) or (1% 1) ( 2% 1) and so on. And also, the grid input can be bigger or smaller than the user writing for numOne and num2.

I am trying to figure out how the layout of this grid has been started using System.out.print () for each count, except for the first time, X amount of TRS ults After initializing numOne to print one. This is probably not the best way from there, but since I'm starting, the only thing I can do is print out stuff. Besides, the problem I am facing is that I am not getting the result which I want.

I have the code:

  int x = 1; Int y = 1; Int numOne; Int numTwo; Scanner input = new java.util.Scanner (System.in); // first value system.out.println ("first number:"); NumOne = input.nextInt (); Whereas (x & lt; = numOne) {System.out.print (""); System.out.print (x + ""); X ++; } // second value System.out.println ("Second Number:"); NumTwo = input.nextInt (); Println (numTwo); Int tResult = (x% y); While (y  

Updated reply:

< P> Using a loop, following what you are trying to achieve, is one of the following.

  public static zero main (string [] args) {int numone; Int numTwo; Scanner input = new java.util.Scanner (System.in); // Get the first value System.out.println ("First Number:"); NumOne = input.nextInt (); // Get another price System.out.println ("Second Number:"); NumTwo = input.nextInt (); Input.close (); Int x = 1; Int y = 1; System.out.print (""); Whereas (x & lt; = numone) {System.out.print ("[x =" + x + "]"); X ++; } X = 1; Y = 1; While (y & lt; = num2) {System.out.println (); System.out.print ("[y =" + y + "]"); Whereas (x & lt; = numone) {int tResult = x% y; System.out.print ("[+ (+ +" + "+" + "+" + y + "+ + + + + + +"] "); X ++;} Y ++; X = 1; Sample Output: First Number: 4 Second Number: 5 [x = 1] [x = 2] [x = 3] [X = 4] [or = 1] [(1% 1) 0 ] [(2% 1) 0] [(3% 1) 0] [(4% 1) 0] [or = 2] [(1% 2] 1] [(2% 2) 0] [(3% 2] [(3% 3) 0] [(4% 3) 1] [(4% 2) 0] [or = 3] [(1% 3) 1] [(2% 3) Or = 4] [[1% 4] 1] [(2% 4) 2] [(3% 4) 3] [(4% 4) 0] [or = 5] [(1% 5) 1] [ (2% 5) 2] [(3% 5) 3] [(4% 5) 4]  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -