Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class CustomerTest
- {
- public static void main(String[] args)
- {
- double totalSales = 0;
- ArrayList<String> customerList;
- customerList = new ArrayList<String>();
- ArrayList<Double> salesList;
- salesList = new ArrayList<Double>();
- Scanner myScanner = new Scanner(System.in);
- boolean done = true;
- do
- {
- Customer aCustomer = new Customer();
- System.out.println("1) Add a new customer \n 2) Print all customers \n 3) Compute and print the total sales \n 4) Quit");
- int choice = Integer.parseInt(myScanner.nextLine());
- if (choice == 1)
- {
- System.out.print("Add a new customer ");
- String answer = myScanner.nextLine();
- aCustomer.setName(answer);
- System.out.print("Enter their sales ");
- String answer2 = myScanner.nextLine();
- double answer3 = Double.parseDouble(answer2);
- aCustomer.setSales(answer3);
- for(int i = 1; i < salesList.size(); i++)
- {
- totalSales = totalSales + answer3;
- }
- customerList.add(aCustomer);
- }
- else if(choice == 2)
- {
- System.out.println("Customers: " + customerList);
- System.out.println("Sales: " + salesList);
- }
- else if(choice == 3)
- {
- System.out.println("Total sales: $" + totalSales);
- }
- else if(choice == 4)
- {
- System.out.println("Goodbye *Bows gracefully*");
- done = false;
- }
- else
- System.out.println("Invalid Choice");
- }
- while (done);
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement