skipter

Beverage Labels - C# Fundamentals

May 29th, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ConsoleApp8
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             var productName = Console.ReadLine();
  13.             var volume = double.Parse(Console.ReadLine());
  14.             var energyContent = double.Parse(Console.ReadLine());
  15.             var sugarContent = double.Parse(Console.ReadLine());
  16.  
  17.             var diff = volume / 100;
  18.             var currentEnergy = energyContent * diff;
  19.             var currentSugar = sugarContent * diff;
  20.  
  21.             Console.WriteLine($"{volume}ml {productName}:");
  22.             Console.WriteLine($"{currentEnergy}kcal, {currentSugar:F1}g sugars");
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment