Advertisement
Guest User

Book Orders

a guest
Aug 27th, 2014
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.33 KB | None | 0 0
  1. using System;
  2.  
  3.     class BookOrders
  4.     {
  5.         static void Main()
  6.         {
  7.             int orders = int.Parse(Console.ReadLine());
  8.             decimal sum = 0;
  9.             int booksSum = 0;
  10.             for (int i = 0; i < orders; i++)
  11.             {
  12.                 int packets = int.Parse(Console.ReadLine());
  13.                 int booksPacket = int.Parse(Console.ReadLine());
  14.                 decimal bookPrice = decimal.Parse(Console.ReadLine());
  15.                 int books = packets * booksPacket;
  16.                 int discount = 0;
  17.                 int index = packets;
  18.                 decimal bookPriceOrder = 0;
  19.                 if (index >= 10 && index < 20)
  20.                 {
  21.                     discount = 5;
  22.                 }
  23.  
  24.                 else if (index >= 20 && index < 30)
  25.                 {
  26.                     discount = 6;
  27.                 }
  28.  
  29.                 else if (index >= 30 && index < 40)
  30.                 {
  31.                     discount = 7;
  32.                 }
  33.  
  34.                 else if (index >= 40 && index < 50)
  35.                 {
  36.                     discount = 8;
  37.                 }
  38.  
  39.                 else if (index >= 50 && index < 60)
  40.                 {
  41.                     discount = 9;
  42.                 }
  43.  
  44.                 else if (index >= 60 && index < 70)
  45.                 {
  46.                     discount = 10;
  47.                 }
  48.  
  49.                 else if (index >= 70 && index < 80)
  50.                 {
  51.                     discount = 11;
  52.                 }
  53.  
  54.                 else if (index >= 80 && index < 90)
  55.                 {
  56.                     discount = 12;
  57.                 }
  58.  
  59.                 else if (index >= 90 && index < 100)
  60.                 {
  61.                     discount = 13;
  62.                 }
  63.  
  64.                 else if (index >= 100 && index < 110)
  65.                 {
  66.                     discount = 14;
  67.                 }
  68.  
  69.                 else if (index >= 110)
  70.                 {
  71.                     discount = 15;
  72.                 }
  73.                 decimal bookDiscount = bookPrice - discount * bookPrice / 100;
  74.                 bookPriceOrder = (decimal)books * bookDiscount;
  75.                 sum += bookPriceOrder;
  76.                 booksSum += booksPacket * packets;
  77.             }
  78.             Console.WriteLine(booksSum);
  79.             Console.WriteLine("{0:F2}", sum);
  80.         }
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement