Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class BeverageLabels {
- public static void main(String[] args) {
- Scanner scan=new Scanner(System.in);
- DecimalFormat df = new DecimalFormat("#.#######");
- String Drink=scan.nextLine();
- int Milliliters=Integer.parseInt(scan.nextLine());
- double KalPer100ml=Double.parseDouble(scan.nextLine());
- double SugarPer100ml=Double.parseDouble(scan.nextLine());
- double Kal=KalPer100ml/100*Milliliters;
- double Sugar=SugarPer100ml/100*Milliliters;
- System.out.printf("%dml %s:%n" +
- "%skcal, %sg sugars",Milliliters,Drink,df.format(Kal),df.format(Sugar));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement