Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Linq;
- namespace RegexEx
- {
- class Program
- {
- static void Main(string[] args)
- {
- int tripInMiles = int.Parse(Console.ReadLine());
- double tripInKms = tripInMiles * 1.609344;
- double totalQuantityOfBeers = 0;
- string input = "";
- while ((input = Console.ReadLine())!= "trip ended")
- {
- //string[] info = input.Split(", ");
- // string name = info[0];
- // double km = double.Parse(info[1]);
- // double beers = double.Parse(info[2]);
- string name = input;
- double km = double.Parse(Console.ReadLine());
- double beers = double.Parse(Console.ReadLine());
- double beersPerKm = beers / km;
- totalQuantityOfBeers += beersPerKm * tripInKms;
- }
- Console.WriteLine($"Beers needed for the trip: {Math.Ceiling(totalQuantityOfBeers)}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement