/** * Second attempt at a class for storing and distributing * key information about a charity. Adds a constructor. * * @author ggtowell * Created: Nov 2023 */ public class Charity5 { private String name; private int donationTarget; private int donationsReceived; public Charity5(String nm, int dt, int dr) { this.name = nm; this.donationTarget = dt; this.donationsReceived = dr; } public String getName() { return name; } public int getDonationTarget() { return donationTarget; } public int getDonationsReceived() { return donationsReceived; } public void adjustDonationsReceived(int dr) { donationsReceived += dr; } public double percentageOfGoal() { return (double) (donationsReceived * 100) / donationTarget; } public String toString() { return name + " has a donation target of " + donationTarget + ". It has received " + donationsReceived + " which is " + percentageOfGoal() + " of its goal."; } }