svetlozar_kirkov

Book Orders

Sep 18th, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.24 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. using System.Threading;
  4.  
  5. namespace BookOrders
  6. {
  7.     class BookOrders
  8.     {
  9.         static void Main()
  10.         {
  11.             Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");
  12.  
  13.             int orders = int.Parse(Console.ReadLine());
  14.             int[] packets = new int[orders];
  15.             int[] books = new int[orders];
  16.             double[] prices = new double[orders];
  17.             int[] discounts = new int[orders];
  18.             double[] pricesNew = new double[orders];
  19.            
  20.             for (int i = 0; i < orders; i++)
  21.             {
  22.                 packets[i] = int.Parse(Console.ReadLine());
  23.                
  24.                 if (packets[i] < 10)
  25.                 {
  26.                     discounts[i] = 0;
  27.                 }
  28.                 else if (packets[i] >= 110)
  29.                 {
  30.                     discounts[i] = 15;
  31.                 }
  32.                 else
  33.                 {
  34.                     int temp = 5;
  35.  
  36.                     for (int k = 10; k < 110; k+=10)
  37.                     {
  38.  
  39.                         if (packets[i] >= k && packets[i] < k + 10)
  40.                         {
  41.                             discounts[i] = temp;
  42.                             break;
  43.                         }
  44.                         else
  45.                         {
  46.                             temp++;
  47.                         }
  48.                     }
  49.                 }
  50.                
  51.                 books[i] = int.Parse(Console.ReadLine());
  52.                 prices[i] = double.Parse(Console.ReadLine());
  53.             }
  54.  
  55.             for (int m = 0; m < orders; m++)
  56.             {
  57.                 pricesNew[m] = (packets[m] * books[m] * prices[m]) - ((packets[m] * books[m] * prices[m]) * discounts[m]/100);
  58.             }
  59.  
  60.             double totalSum = 0;
  61.            
  62.             foreach (var item in pricesNew)
  63.             {
  64.                 totalSum+= item;
  65.             }
  66.  
  67.             int totalBooks = 0;
  68.  
  69.             for (int z = 0; z < orders; z++)
  70.             {
  71.                 totalBooks += packets[z] * books[z];
  72.             }
  73.  
  74.             Console.WriteLine(totalBooks);
  75.             Console.WriteLine(totalSum.ToString("F"));
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment