Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Friendly_Trip
- {
- class Program
- {
- static void Main(string[] args)
- {
- var distance = int.Parse(Console.ReadLine()); //0...10 000km
- var norm = int.Parse(Console.ReadLine()); //0.100 liters/100km
- var priceFuel = double.Parse(Console.ReadLine()); //0...50.0 lv./liter
- var budget = int.Parse(Console.ReadLine()); //0...100 000 разполагаема сума
- double sumLitres = distance * norm / 100; //общо гориво
- double sum = sumLitres * priceFuel; //сума за горивото
- double difference = Math.Abs(sum - budget); //разлика
- double forEach = budget / 5.0; //допълнително от всеки
- if (sum <= budget)
- {
- Console.WriteLine($"You can take a trip. {difference:f2} money left.");
- }
- else
- {
- Console.WriteLine($"Sorry, you cannot take a trip. Each will receive " +
- $"{forEach:f2} money.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement