Page 395 - Introduction to Programming with Java: A Problem Solving Approach
P. 395
9.7 Problem Solving with Class Members and Instance Members in a Linked List Class (Optional) 361
/******************************************************************
*
FundRaiser.java
Dean & Dean
This program manages fund-raising agents.
******************************************************************/
*
*
*
import java.util.Scanner;
public class FundRaiser
{
public static final double GOAL = 10000.00;
//***************************************************************
public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
int numberOfAgents;
double totalValue;
String name;
System.out.print("Enter total number of agents: ");
Apago PDF Enhancer
stdIn.nextLine();
numberOfAgents = stdIn.nextInt();
for (int i=0; i<numberOfAgents; i++)
{
}
// end FundRaiser class
}
// end main
}
System.out.print("Enter agent name: ");
name = stdIn.nextLine();
new Agent(name);
Agent.addAllValues();
totalValue = Agent.getAllValues();
System.out.printf("Total value = $%,.2f\n", totalValue);
do
{
Notice that this driver does not need to keep track of any object references.
All subsequent access to Agent class is through class methods.
} while (totalValue < GOAL);
System.out.println("Time to Spend!");
Figure 9.8 Top level of FundRaiser program
This drives the Agent class in Figure 9.9a and 9.9b.