Use JAVA to complete the following task A family has decide
Use JAVA to complete the following task.
- A family has decided to build a group of totems to mark the center of their community. For this project, each pole will consist of an eagle at the top, followed by cycles of the following two figures: whale and human. The figures are stylized in our system as follows:
- Write and test three static methods, one to output each of the stylized figures that will be on the totems. The method signatures for those methods are as follows: public static void eagle(); public static void whale(); public static void human();
- Test your methods by writing a main method that calls all three and confirms to you that the methods produce exactly the figures above. (This main method should be considered your ‘tester’: you create it to test your own work.)
-Your program should output an appropriate title screen.
- Ask the user to input the number of figures on the pole.
- Use the following algorithm, output up to (may be smaller) the specified number of figures: there is always only 1 eagle on each pole, at the top, and whale-human figures are always paired, with a human below each whale.
Eagle - 5 11-111111111-1\\ \\//WWW /////-~~~~~war ~ ~ ~ ~ \\ l. I l/-~..........\\\\\\\\\\ Whale: 1---- ... ., , ! ,\'I \\I all\\Solution
public class TowersOfHanoi {
public void solve(int n, String start, String auxiliary, String end) {
if (n == 1) {
System.out.println(start + \" -> \" + end);
} else {
solve(n - 1, start, end, auxiliary);
System.out.println(start + \" -> \" + end);
solve(n - 1, auxiliary, start, end);
}
}
public static void main(String[] args) {
TowersOfHanoi towersOfHanoi = new TowersOfHanoi();
System.out.print(\"Enter number of discs: \");
Scanner scanner = new Scanner(System.in);
int discs = scanner.nextInt();
towersOfHanoi.solve(discs, \"A\", \"B\", \"C\");
}
}
