Question: package edu.buffalostate.cis 4 2 5 . sp 2 4 . put - your - username - here; / * * * File: Donor.java * *

package edu.buffalostate.cis425.sp24.put-your-username-here;
/**
* File: Donor.java
*
* Description: This class represents a donor to an
* organization. It stores the donor's name and rating.
* The main() method tests the class's methods.
*
* Requirements:
*1) Add a new level "low" to this class (in addition to * "high", "medium", "none")
*2) Add a new method:
* public void updateRating(double amt){} which recalculates
* a donor's rating according to the following schedule:
* a) amt =0- none
* b) amt < $100- low
* c) amt >= $100 and amt < $1000- medium
* d) amt >= $1000- high
* updateRating() should change the instance variable:
* rating to the new value
*3) Modify this template to include an address variable and
* change the constructor to accept this new variable
*(along with the parameters). Basically, the object
* stores the donor's name, address and rating
*4) Modify main() to print out donor address also
*5) Create a new donor (donor4) with an initial "low" rating,
* a) then let donor4 contribute $150,
* b) print this donor's new rating to the console
*6 Modify the rest of the program (as needed) so that it
* compiles and runs correctly
*
*/
/**
*
* @author put-your-name-here
*
*/
public class Donor {
private String name ="no name";
private String rating = "none";
/**
* Donor() constructor sets the object's name and rating
* @param str -- a String giving the donor's name
* @param str2-- a String giving the donor's rating
*/
public Donor(String str, String str2){
name = str;
rating = str2;
// Hint: add address string here
}
/**
* getName() returns the donor's name
* @return a String giving the person's name
*/
public String getName(){
return name;
}
// Hint: add accessor method to get the address
/**
* getRating() returns the donor's rating
* @return a String giving the person's rating
*/
public String getRating(){
// This if could be a switch/case conditional
// add check for low level
if (rating.equals("high")){
return "high";
} else if (rating.equals("medium")){
return "medium";
} else {
return "none";
}
}
/**
* main() creates three Donor instances and tests this classes methods.
*/
public static void main (String argv[]){
// Hint: add address string to the three (3) constructors
Donor donor1= new Donor("put-donor1-name-here", "high");
// Hint: add address string to the output
System.out.println("Donor's name is "+ donor1.getName());
System.out.println(donor1.getName()+"'s rating is "+ donor1.getRating());
Donor donor2= new Donor("put-donor2-name-here", "medium");
System.out.println("Donor's name is "+ donor2.getName());
System.out.println(donor2.getName()+"'s rating is "+ donor2.getRating());
Donor donor3= new Donor("put-donor3-name-here", "none");
System.out.println("Donor's name is "+ donor3.getName());
System.out.println(donor3.getName()+"'s rating is "+ donor3.getRating());
// add code to construct donor4 and print donor4 info
// add code to increase donor4's amount (updateRating())
// and print out new donor4 rating
}// end main()
}// end Donor class
When you have this Exercise ready for me to view and grade, you should upload your Donor.java file here.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!