SHARE
TWEET

Going Home

MartinGeorgiev Nov 22nd, 2018 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top