mustafov

Book Orders

Sep 3rd, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.14 KB | None | 0 0
  1. // Book Orders
  2. //Bai NakMan has his own book store business. He often makes orders for new books, but the procedure is kind of complicated. You //will be given the number of orders N. Each order holds, number of packets, amount of books per packet and price per book. //Depending on the number of packets, you get different discount ranging from 5% to 15%.  If the packets in the order are less than //10, there is no discount. Otherwise they have the following discounts (10-19 packets = 5% discount, 20-29 = 6%, 30-39 = 7%, ..., //100-109 = 14%). If the packets are 110 or more, there is 15% discount for all books. Your task is to sum how many books Bai //NakMan has bought and the end price of all books. Check the examples below to understand your task better.
  3.  
  4.  
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10.  
  11. namespace ConsoleApplication2
  12. {
  13.     class Program
  14.     {
  15.         static void Main(string[] args)
  16.         {
  17.             int n = int.Parse(Console.ReadLine());
  18.             int firstLine = 0;
  19.             double secondLine = 0;
  20.             for (int i = 0; i < n; i++)
  21.             {
  22.                 int packets = int.Parse(Console.ReadLine());
  23.                 int perPacket = int.Parse(Console.ReadLine());
  24.                 double price = double.Parse(Console.ReadLine());
  25.  
  26.                 if (packets > 9 && packets < 20)
  27.                 {
  28.                     price = price * 0.95;
  29.                 }
  30.                 else if (packets > 19 && packets < 30)
  31.                 {
  32.                     price = price * 0.94;
  33.                 }
  34.                 else if (packets > 29 && packets < 40)
  35.                 {
  36.                     price = price * 0.93;
  37.                 }
  38.                 else if (packets > 39 && packets < 50)
  39.                 {
  40.                     price = price * 0.92;
  41.                 }
  42.                 else if (packets > 49 && packets < 60)
  43.                 {
  44.                     price = price * 0.91;
  45.                 }
  46.                 else if (packets > 59 && packets < 70)
  47.                 {
  48.                     price = price * 0.90;
  49.                 }
  50.                 else if (packets > 69 && packets < 80)
  51.                 {
  52.                     price = price * 0.89;
  53.                 }
  54.                 else if (packets > 79 && packets < 90)
  55.                 {
  56.                     price = price * 0.88;
  57.                 }
  58.                 else if (packets > 89 && packets < 100)
  59.                 {
  60.                     price = price * 0.87;
  61.                 }
  62.                 else if (packets > 99 && packets < 110)
  63.                 {
  64.                     price = price * 0.86;
  65.                 }
  66.                 else if (packets > 109)
  67.                 {
  68.                     price = price * 0.85;
  69.                 }
  70.  
  71.                 int allBooks = packets * perPacket;
  72.                 double allBooksCosts = allBooks * price;
  73.  
  74.                 firstLine += allBooks;
  75.                 secondLine += allBooksCosts;
  76.             }
  77.  
  78.            
  79.             Console.WriteLine(firstLine);
  80.             Console.WriteLine("{0:0.00}",secondLine);
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment