Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Problem5
- {
- public static void main(String[] args)
- {
- double sugar = 100;
- double alcohol = 0;
- double vinegar = 0;
- double totalAlcohol = 0;
- double maxAlcohol = 0;
- int day = 0;
- while (true) {
- alcohol = 0.10 * sugar;
- totalAlcohol += alcohol;
- sugar -= alcohol;
- vinegar = (0.01 * totalAlcohol);
- totalAlcohol-=vinegar;
- if (maxAlcohol < totalAlcohol) {
- maxAlcohol = totalAlcohol;
- day++;
- }
- else {
- break;
- }
- }
- System.out.println(day);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement