Write a java program that reads from the keyboard the starting positions and constructs the rest of the magic triangle based on those integer numbers. Output to the screen the completed magic triangle in the form of a triangle shape and the number all the sides equal to. Depending on the inputs there may be several possible solutions. In that case, any solution will do. In a few cases there may be no solution, in which case output "No solution". Finally, the program should ask if the user wants to run the program again. Check case. Refer to the sample output below. Sample Run: Enter the three triangle starting positions: 2 7 8 Completed triangle: 5 8 9 1 2 6 7 3 4 All sides total: 20 Run again (Y/N): y Enter the three triangle starting positions: 5 2 7 No solutionRun again (Y/N): N
Write a java
Sample Run:
Enter the three triangle starting positions: 2 7 8
Completed triangle: 5 8 9 1 2 6 7 3 4
All sides total: 20
Run again (Y/N): y
Enter the three triangle starting positions: 5 2 7
No solutionRun again (Y/N): N
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images