Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Develop exactly one class and create three instances john, mary and jane of t

ID: 3888178 • Letter: 1

Question

1. Develop exactly one class and create three instances john, mary and jane of the class. These three objects share a tank of water with a capacity of 1234.5 gallons. The class equips three methods. One allows pouring water into the tank, another checks water remaining in the tank, and the other retrieves water out of the tank Declare the amount of gallons of water in the tank as a primitive data field in the class. The water retrieving method not only deducts water out of the tank but also accumulates the usage for individual persons, i.e., flowering (45%) and showering (55%). Provide a main method to start the program execution and model the following behavior. Initialize the tank to have 1200 gallons of water. Next, john pours 95.35 gallons of water into the water tank and then he views the remaining. Later, mary takes away 250.75 gallons. Jane then pours in 100.75 gallons. Afterwards, john retrieved 120.8 gallons and jane retrieved 322.46 gallons. Finally, mary checked the remaining of the tank. At the very end, print out the accumulated water usage for each person in the two usage categories. (2.5 pts)

Explanation / Answer

Here is your answer in Java. I hope you will like it

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chegg.september;

/**
*
* @author Sam
*/
public class TankUser {
    static double waterRemaining;
    String name;
    double flowering, showering;
    void measureWaterLevel() {
        System.out.println(name + " checked " + waterRemaining + " liters of water left.");
    }
  
    void pour(double amount) {
        waterRemaining += amount;
        System.out.println(name + " pored " + amount + " liters of water in the tank.");
    }
  
    void retrive(double amount){
        waterRemaining += amount;
        System.out.println(name + " pored " + amount + " liters of water in the tank.");
        flowering += amount*0.45;
        showering += amount*0.55;
    }

    public TankUser(String name) {
        this.name = name;
        flowering = 0;
        showering = 0;
    }

    @Override
    public String toString() {
        return name + " used " + flowering + " liters of water for flowering till date" + " " +
                name + " used " + showering + " liters of water for flowering till date";
  
    }
  
    public static void main(String[] args) {
        TankUser john = new TankUser("John");
        TankUser jane = new TankUser("Jane");
        TankUser mary = new TankUser("Mary");
      
        waterRemaining = 1200;
      
        john.pour(95.35);
        john.measureWaterLevel();
        mary.retrive(250.75);
        jane.pour(100.75);
        john.retrive(120.8);
        jane.retrive(322.46);
        mary.measureWaterLevel();
      
        System.out.println(john);
        System.out.println(jane);
        System.out.println(mary);
    }
}