kirililchev3

Beverage Labels

May 16th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3. public class EmployeeData {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner console = new Scanner(System.in);
  7.         String name = console.nextLine();
  8.         int volume = Integer.parseInt(console.nextLine());
  9.         int energy = Integer.parseInt(console.nextLine());
  10.         int sugar = Integer.parseInt(console.nextLine());
  11.         double kcal = volume*(energy/100.0);
  12.         double g = volume*(sugar/100.0);
  13.  
  14.         DecimalFormat formatter = new DecimalFormat("#.##");
  15.         System.out.format("%sml %s:%n",formatter.format(volume), name);
  16.         System.out.format("%skcal, %sg sugars", formatter.format(kcal), formatter.format(g));
  17.     }
  18. }
Add Comment
Please, Sign In to add comment