Advertisement
MartinGeorgiev

Going Home

Nov 22nd, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int km = int.Parse(Console.ReadLine());
  10.             double consuption = double.Parse(Console.ReadLine());
  11.             double gasolinePrice = Double.Parse(Console.ReadLine());
  12.             int money = int.Parse(Console.ReadLine());
  13.  
  14.             double litersFuel = km * consuption / 100;
  15.             double cost = litersFuel * gasolinePrice;
  16.             double available = money - cost;
  17.  
  18.             if (available >= 0)
  19.             {
  20.                
  21.                 Console.WriteLine($"You can go home. {available:f2} money left.");
  22.  
  23.             }
  24.             else
  25.             {
  26.              
  27.                 Console.WriteLine($"Sorry, you cannot go home. Each will receive {money*1.0/5:f2} money.");
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement