Advertisement
Spocoman

Cat Diet

Sep 2nd, 2024
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double fats = Double.parseDouble(scanner.nextLine()),
  7.                 proteins = Double.parseDouble(scanner.nextLine()),
  8.                 carbohydrates = Double.parseDouble(scanner.nextLine()),
  9.                 calories = Double.parseDouble(scanner.nextLine()),
  10.                 water = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double caloriesPerGram = (100 - water) * (calories / (calories * fats / 9
  13.                 + calories * proteins / 4 + calories * carbohydrates / 4));
  14.  
  15.         System.out.printf("%.4f\n", caloriesPerGram);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement