Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace BookOrders
- {
- using System;
- using System.Collections.Generic;
- public class BookOrders
- {
- public static void Main()
- {
- 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 = books[i] * books[i + 1];
- double tempCost = GetDiscountedPrice(books, i);
- double tempPrice = tempBooks * tempCost;
- totalPrice += tempPrice;
- totalBooks += tempBooks;
- }
- Console.WriteLine(totalBooks);
- Console.WriteLine("{0:F2}", totalPrice);
- }
- private static double GetDiscountedPrice(List<double> books, int i)
- {
- double tempCost = books[i + 2];
- if (books[i] >= 10 && books[i] <= 19)
- {
- tempCost *= 0.95;
- }
- else if (books[i] >= 20 && books[i] <= 29)
- {
- tempCost *= 0.94;
- }
- else if (books[i] >= 30 && books[i] <= 39)
- {
- tempCost *= 0.93;
- }
- else if (books[i] >= 40 && books[i] <= 49)
- {
- tempCost *= 0.92;
- }
- else if (books[i] >= 50 && books[i] <= 59)
- {
- tempCost *= 0.91;
- }
- else if (books[i] >= 60 && books[i] <= 69)
- {
- tempCost *= 0.9;
- }
- else if (books[i] >= 70 && books[i] <= 79)
- {
- tempCost *= 0.89;
- }
- else if (books[i] >= 80 && books[i] <= 89)
- {
- tempCost *= 0.88;
- }
- else if (books[i] >= 90 && books[i] <= 99)
- {
- tempCost *= 0.87;
- }
- else if (books[i] >= 100 && books[i] <= 109)
- {
- tempCost *= 0.86;
- }
- else if (books[i] >= 110)
- {
- tempCost *= 0.85;
- }
- return tempCost;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement