What do I put for coding for these two problems?
5 points Status: Not Submitted The Battleship class represents a single battleship. Each battleship has the instance variables name (the type of ship), power (the power level of this ship's attack), and health (declines with attacks). Fill in the instance methods isAttacked and stillFloating in Battleship. The damage done by the attacking ship is determined as follows: If the attack power of the ship is less than 4, the ship inflicts 3 damage If the attack power of the ship is less than 8, the ship inflicts 5 damage If the attack power of the ship is 8 or more, the ship inflicts 7 damage The method isAttacked updates the attacked ship's health accordingly. In main, you should be able to see that the differing levels of attack power yield different amounts of damage. stillfloating returns a boolean indiciating if the ship is still floating. The ship is still floating as long as the health is greater than 0. While you can use an if statement, remember you can also directly return the result of a boolean expression eg return x > Y; Status: Not Submitted 3.4.9: Battleships Save Submit Continue FILES ShipTesterjave L Battleship.java MONOSOM 1 public class ShipTester 2-{ 3 public static void main(String[] args) { 5 Battleship sub - new Battleship ("submarine", 6); 6 Battleship raft - new Battleship("raft", 2); Battleship destroyer - new Battleship"destroyer", 9); System.out.println(sub); System.out.println("Sub has power " + sub.getPower()); 12 System.out.println(raft); 13 System.out.println("Raft has power " + raft.getPower()); 14 15 System.out.println(destroyer) 16 System.out.println("Destroyer has power + destroyer.get Power 17 18 System.out.println(" Raft attacks Sub"); 19 sub. IsAttacked craft.getPower()); 20 System.out.println(sub): 21 22 System.out.println(" Destroyer attacks Raft"); 23 raft.isAttacked (destroyer.getPower); 24 System.out.println(raft); 25 26 System.out.println(" Sub attacks Destroyer"); 27 destroyer isAttacked(sub.getPower()) 28 System out.println(destroyen); 29 Status: Not Submitted FILES ShipTester.java D Battleship.java 3.4.9: Battleships Save Submit Continue 1 public class Battleship 2-1 private String name; // type of ship 4 private int power; // power of attack in range 1 10] 5 private int health; // health of the ship 7 // Constructor public Battleship(String shipType, int attackPower) 9- { 10 name - shipType; 11 power - attackPower; 12 health - 100; 13 3 14 15 // Modifies the health of the battleship 16 public void isAttacked (int attackPower) 17 - { 18 - if (this.power 26 27 11 Returns true If the health of 28 W the ship is greater than e 29 public boolean stillFloating) e; 3 B ShipTester java D Battleship.java 24 25 26 27 28 29 30 - 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 49 49 11 getter for health public int getHealth (( return health; W/ Returns the power of the ship public int getPower() { return power; > W Returns string representation in the form 1/ Battleship name public String toString() { return name + "(" + health + "); 3 50 51 52 5 points This program reads in two numbers from the user, dividend and divisor, and prints out whether dividend is evenly divisible by divisor For example, one run of the program may look like this: Enter the dividend: 10 Enter the divisor: 5 10 is divisible by 5! Because 5 goes into 10 twice. 10 is evenly divisible by 5. Another run may look like this: Enter the dividend: 10 Enter the divisor: 8 10 is not divisible by 8! Because 10 / 8 is 1.25, 10 is not evenly divisible by 8. The Bug The problem is that if the user inputs o for the divisor, the program tries to divide by O and the program crashes. Your Job Your job is to use Short Circuiting to prevent the condition inside the if Enter the divisor: 5 10 is divisible by 5! Because 5 goes into 10 twice. 10 is evenly divisible by 5. Another run may look like this: Enter the dividend: 10 Enter the divisor: 8 10 is not divisible by 8! Because 10/8 is 1.25, 10 is not evenly divisible by 8. The Bug The problem is that if the user inputs o for the divisor, the program tries to divide by O and the program crashes. Your Job: Your job is to use Short Circuiting to prevent the condition inside the if statement from dividing by 0. Your program should be able to produce the following output: Enter the dividend: 10 Enter the divisor: 0 10 is not divisible by ! Status: Not Submitted 3.5.8: Divisibility Submit - Continue lii FILES 1 import java.util.Scanner: 2 3 public class Divisibility 4 - 5 public static void main(String[] args) 6- 7 Scanner Input = new Scanner(System.in); 8 9 } le 11 12 13 Divisibilityjava