0 LIKES LikeUnLike
Magic SquareArrange the number 1-9 in the boxes below such that each row and each column adds up to 15. Use each number only once.********6*1*8* 15********7*5*3* 15********2*9*4* 15*******15 15 15Congratulations! You solved the Magic Square!Write a complete Java program that will ask the user to input an integer number from 1 to 9 only and specify the row and column where the input will be stored. After inputting a number display the magic square with the corresponding sum for each row and column. Check the sum if it equals to 15.Sample run:C:\>java MagicSquare<press enter>********0*0*0* 0********0*0*0* 0********0*0*0* 0******* 0 0 0Row: 0<press enter>Column: 0<press enter>Value: 6<press enter>********6*0*0* 6********0*0*0* 0********0*0*0* 0******* 6 0 0Row: 1<press enter>Column:1<press enter>Value: 5<press enter>********6*0*0* 6********0*5*0* 5********0*0*0* 0******* 6 5 0Row: 2<press enter>Column:2<press enter>Value: 4<press enter>********6*0*0* 6********0*5*0* 5********0*0*4* 4******* 6 5 4Row: 0<press enter>Column:1<press enter>Value: 1<press enter>********6*1*0* 7********0*5*0* 5********0*0*4* 4******* 6 6 4Row: 0<press enter>Column:2<press enter>Value: 8<press enter>********6*1*8* 15********0*5*0* 5********0*0*4* 4******* 6 6 12And so forth and so on until the sum of row and column is 15 the program will be automatically terminated. The program can be terminated if the input for the row, column and value are -1.********0*0*0* 0********0*0*0* 0********0*0*0* 0******* 0 0 0Row: -1<press enter>Column: -1<press enter>Value: -1<press enter>Program Terminated!------------Thanks-----------
Tags:
Report (0) (0) | earlier
Latest activity: earlier. This question has 1 answers.