This repository has been archived on 2026-10-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
projectstem-keys-java/Fundraiser/Fundraiser.java
T
2024-03-11 12:33:03 -07:00

23 lines
496 B
Java

public class Fundraiser {
private double target;
private double total;
private double count = 0;
public Fundraiser(double amount) {
total = amount;
}
public double averageDonation() {
return (count == 0) ? 0.0 : total / count;
}
public void addDonation(double amount) {
total += amount;
count++;
}
public double distanceToTarget() {
return (total >= target) ? 0.0 : target - total;
}
}