Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace labexercise
- {
- class Program
- {
- static void Main(string[] args)
- {
- Travelling();
- //CinemaTickets();
- }
- public static void Travelling()
- {
- string destination = Console.ReadLine();
- double budget = double.Parse(Console.ReadLine());
- double neededMoney = 0;
- while (destination != "End")
- {
- while (neededMoney < budget)
- {
- double savedMoney = double.Parse(Console.ReadLine());
- neededMoney += savedMoney;
- if (neededMoney >= budget)
- {
- Console.WriteLine($"Going to {destination}!"); ;
- neededMoney = 0;
- break;
- }
- }
- destination = Console.ReadLine();
- if (destination != "End")
- {
- budget = double.Parse(Console.ReadLine());
- }
- }
- }
- public static void CinemaTickets()
- {
- string input = Console.ReadLine();
- int studentCounter = 0;
- int standardCounter = 0;
- int kidsCounter = 0;
- int totalTickets = 0;
- int totalKidsCounter = 0;
- int totalStadardCounter = 0;
- int totalStudentCounter = 0;
- while (input != "Finish")
- {
- int freeSeats = int.Parse(Console.ReadLine());
- for (int ticketCounter = 1; ticketCounter <= freeSeats; ticketCounter++)
- {
- string typeOfTicket = Console.ReadLine();
- switch (typeOfTicket)
- {
- case "student": studentCounter++; totalStudentCounter++; break;
- case "standard": standardCounter++; totalStadardCounter++; break;
- case "kid": kidsCounter++; totalKidsCounter++; break;
- default:
- break;
- }
- if (typeOfTicket == "End")
- {
- break;
- }
- totalTickets++;
- }
- if (freeSeats > (studentCounter + standardCounter + kidsCounter))
- {
- Console.WriteLine($"{input} - {((100.00 / freeSeats) * (studentCounter + standardCounter + kidsCounter)):F2}% full.");
- }
- else if (freeSeats == (studentCounter + standardCounter + kidsCounter))
- {
- Console.WriteLine($"{input} - 100.00% full.");
- }
- studentCounter = 0;
- standardCounter = 0;
- kidsCounter = 0;
- input = Console.ReadLine();
- }
- Console.WriteLine($"Total tickets: {totalTickets}");
- Console.WriteLine($"{((100.00 / totalTickets) * totalStudentCounter):F2}% student tickets.");
- Console.WriteLine($"{((100.00 / totalTickets) * totalStadardCounter):F2}% standard tickets.");
- Console.WriteLine($"{((100.00 / totalTickets) * totalKidsCounter):F2}% kids tickets.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement