import java.util.*;
public class TrailerMethod {
  
  
  public static void main(String[] args) { 
     Scanner input = new Scanner(System.in);
     
     int count=0;
     System.out.print("Enter receipt #"+(count+1)+": ");
     int amount = input.nextInt();
     
     int total=0;
     while(amount >=0) { //a negative number serves as the trailer value or sentinel value
       count++;
       total+=amount;
       
       System.out.print("Enter receipt #"+(count+1)+": ");
       amount = input.nextInt();
     
     }
     
     System.out.printf("The total of %d receipts is $%d\n", count, total);
     System.out.printf("The average receipt was $%.2f\n", (double)total/count);
  }
  
  
}


/*while(Boolean test) {
 * 
 *   //body of the while loop
 *}
 */


