Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace BookOrders
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Threading;
- using System.Globalization;
- class BookOrders
- {
- static void Main()
- {
- Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- int n = int.Parse(Console.ReadLine());
- var books = new List<double>();
- for (int i = 0; i < n*3; i++)
- {
- books.Add(double.Parse(Console.ReadLine()));
- }
- double totalBooks = 0;
- double totalPrice = 0;
- for (int i = 0; i < books.Count; i+=3)
- {
- double tempBooks = 0;
- double tempPrice = 0;
- double tempCost = 0;
- tempBooks = books[i] * books[i + 1];
- tempCost = price(books, i, tempCost);
- tempPrice = tempBooks * tempCost;
- totalPrice += tempPrice;
- tempPrice = 0;
- totalBooks += tempBooks;
- tempBooks = 0;
- }
- Console.WriteLine(totalBooks);
- Console.WriteLine("{0:F2}", totalPrice);
- Console.ReadLine();
- }
- private static double price(List<double> books, int i, double tempCost)
- {
- if (books[i] >= 10 && books[i] <= 19)
- {
- tempCost = (double)books[i + 2] - (double)0.5;
- }
- else if (books[i] >= 20 && books[i] <= 29)
- {
- tempCost = (double)books[i + 2] - (double)0.6;
- }
- else if (books[i] >= 30 && books[i] <= 39)
- {
- tempCost = (double)books[i + 2] - (double)0.7;
- }
- else if (books[i] >= 40 && books[i] <= 49)
- {
- tempCost = (double)books[i + 2] - (double)0.8;
- }
- else if (books[i] >= 50 && books[i] <= 59)
- {
- tempCost = (double)books[i + 2] - (double)0.9;
- }
- else if (books[i] >= 60 && books[i] <= 69)
- {
- tempCost = (double)books[i + 2] - (double)1.0;
- }
- else if (books[i] >= 70 && books[i] <= 79)
- {
- tempCost = (double)books[i + 2] - (double)1.1;
- }
- else if (books[i] >= 80 && books[i] <= 89)
- {
- tempCost = (double)books[i + 2] - (double)1.2;
- }
- else if (books[i] >= 90 && books[i] <= 99)
- {
- tempCost = (double)books[i + 2] - (double)1.3;
- }
- else if (books[i] >= 100 && books[i] <= 109)
- {
- tempCost = (double)books[i + 2] - (double)1.4;
- }
- else
- {
- tempCost = (double)books[i + 2] - (double)1.5;
- }
- return tempCost;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement