Advertisement
Osiris1002

Untitled

Dec 18th, 2022
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. package IZPIT;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Cat_Diet {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.  
  9.         double percentMas = Integer.parseInt(scan.nextLine());
  10.         double percentPro = Integer.parseInt(scan.nextLine());
  11.         double percentCoals = Integer.parseInt(scan.nextLine());
  12.         double totalCalories = Integer.parseInt(scan.nextLine());
  13.         double percentWat =  Integer.parseInt(scan.nextLine());
  14.  
  15.         double gramMas = (percentMas * totalCalories / 100) /9 ;
  16.         double gramPro = (percentPro * totalCalories / 100) /4;
  17.         double gramCoal = (percentCoals * totalCalories / 100) /4 ;
  18.  
  19.         double gram = gramCoal + gramMas + gramPro;
  20.         double calPerGram = totalCalories / gram;
  21.         double calories = calPerGram - (percentWat / 100 * calPerGram);
  22.  
  23.  
  24.         System.out.printf("%.4f",calories);
  25.  
  26.     }
  27.  
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement