Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. public class Problem5
  2. {
  3.   public static void main(String[] args)
  4.   {
  5.     double sugar = 100;
  6.     double alcohol = 0;
  7.     double vinegar = 0;
  8.     double totalAlcohol = 0;
  9.     double maxAlcohol = 0;
  10.     int day = 0;
  11.  
  12.     while (true) {
  13.  
  14.       alcohol = 0.10 * sugar;
  15.       totalAlcohol += alcohol;
  16.  
  17.       sugar -= alcohol;
  18.       vinegar = (0.01 * totalAlcohol);
  19.  
  20.       totalAlcohol-=vinegar;
  21.  
  22.       if (maxAlcohol < totalAlcohol) {
  23.         maxAlcohol = totalAlcohol;
  24.         day++;
  25.       }
  26.       else {
  27.         break;
  28.       }
  29.     }
  30.     System.out.println(day);
  31.   }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement