Advertisement
476179

totalsale -loops5

Nov 21st, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. package les;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TotalSale
  6. {
  7. //input daily sales, then adds
  8.  
  9. public static void main(String[] args)
  10. {
  11. Scanner k = new Scanner(System.in);
  12. int days;
  13. double dailys, totals = 0;
  14. System.out.print("how many days do yo u have sales figures:");
  15. days = k.nextInt();
  16. //"it = 1" is initialization expression,
  17. //it == days is test expression
  18. // it++ is update expression
  19. for (int it = 1; it <= days; it++ )
  20. {k.nextLine();
  21. System.out.print("enter sales for day "+it+" : ");
  22. dailys = k.nextInt();
  23. totals += dailys;
  24.  
  25. }
  26. System.out.printf("%.2f", totals);
  27.  
  28.  
  29.  
  30. k.close();
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement