Advertisement
ateyevtm

Untitled

Oct 13th, 2021
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public class Praktikum {
  2.  
  3. public static void main(String[] args) {
  4. double[] expenses = {1772.5, 367.0, 120.6, 2150.2, 874.0, 1.0, 1459.4};
  5. double maxExpense = findMaxExpense(expenses); // Вызовите метод и присвойте maxExpense значение его результата
  6. System.out.println("Самая большая трата недели " + maxExpense);
  7. }
  8.  
  9. public static double findMaxExpense (double[] expenses) {
  10. double max = 0.0;
  11. for (int i = 0; i < expenses.length;i++){
  12. if (expenses[i] > max) {
  13. max = expenses[i];
  14. }
  15. }
  16. return max;
  17. }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement