Page 442 - Introduction to Programming with Java: A Problem Solving Approach
P. 442

                408 Chapter 10 Arrays and ArrayLists
 /*******************************************************************
*
SalesClerksDriver.java
Dean & Dean
This drives the SalesClerks class.
*******************************************************************/
*
*
*
import java.util.Scanner;
public class SalesClerksDriver
{
}
// end SalesClerksDriver
public static void main(String[] args)
{
}
// end main
Scanner stdIn = new Scanner(System.in);
SalesClerks clerks = new SalesClerks(2);
String name;
System.out.print("Enter clerk's name (q to quit): ");
name = stdIn.nextLine();
while (!name.equals("q"))
{
Sample session:
System.out.print("Enter sale amount: ");
clerks.addSale(name, stdIn.nextDouble());
stdIn.nextLineA()p; ago P//DFflusEh nehwlainecer System.out.print("Enter clerk's name (q to quit): "); name = stdIn.nextLine();
// end while
}
clerks.dumpData();
 Enter clerk's name (q to
quit): Daniel
quit): Josh
quit): Amanda
quit): Daniel
quit): Josh
quit): q
Enter sale amount: 6.25
Enter clerk's name (q to
Enter sale amount: 58.12
Enter clerk's name (q
to
to
Enter sale amount: 40
Enter clerk's name (q
Enter sale amount: -6.25
Enter clerk's name (q to
Enter sale amount: 12.88
Enter clerk's name (q to
Daniel: 0.00
Josh: 71.00
Amanda: 40.00
Figure 10.24 Driver for the SalesClerks program in Figures 10.22a, 10.22b, and 10.23











































   440   441   442   443   444