Advertisement
n4wn4w

02. Book Orders22 August 2014

Mar 18th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int orders = int.Parse(Console.ReadLine());
  13.             int totalBooks = 0;
  14.             double totalPrice = 0.0;
  15.             // tuk si vurtim sqka edna poruchaka na kolkoto puti mi e order
  16.             for (int i = 0; i < orders; i++)
  17.             {
  18.          
  19.                 int packets = int.Parse(Console.ReadLine());
  20.                 int booksPerPack = int.Parse(Console.ReadLine());
  21.                 double price = double.Parse(Console.ReadLine());
  22.  
  23.                 int allBooks = packets * booksPerPack;
  24.                 double discount = 0.0;
  25.                 if (packets >= 10 && packets <= 19)
  26.                 {
  27.                     discount = 0.05;
  28.                 }
  29.                 else if (packets >= 20 && packets <= 29)
  30.                 {
  31.                     discount = 0.06;
  32.                 }
  33.                 else if (packets >= 30 && packets <= 39)
  34.                 {
  35.                     discount = 0.07;
  36.                 }
  37.                 else if (packets >= 40 && packets <= 49)
  38.                 {
  39.                     discount = 0.08;
  40.                 }
  41.                 else if (packets >= 50 && packets <= 59)
  42.                 {
  43.                     discount = 0.09;
  44.                 }
  45.                 else if (packets >= 60 && packets <= 69)
  46.                 {
  47.                     discount = 0.10;
  48.                 }
  49.                 else if (packets >= 70 && packets <= 79)
  50.                 {
  51.                     discount = 0.11;
  52.                 }
  53.                 else if (packets >= 80 && packets <= 89)
  54.                 {
  55.                     discount = 0.12;
  56.                 }
  57.                 else if (packets >= 90 && packets <= 99)
  58.                 {
  59.                     discount = 0.13;
  60.                 }
  61.                 else if (packets >= 100 && packets <= 109)
  62.                 {
  63.                     discount = 0.14;
  64.                 }
  65.                 else if (packets >= 110)
  66.                 {
  67.                     discount = 0.15;
  68.                 }
  69.                 else if (packets < 10)
  70.                 {
  71.                     discount = 0.0;
  72.                 }
  73.                 // ((allBooks * price) * discount) tova mi e kolko mi e otstupkata - (price * allBooks)
  74.                 double finalPrice = (price * allBooks) - ((allBooks * price) * discount);
  75.                 totalPrice = totalPrice + finalPrice;
  76.              
  77.                 totalBooks = totalBooks + allBooks;
  78.             }
  79.             Console.WriteLine(totalBooks);
  80.             Console.WriteLine("{0:F2}", totalPrice);
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement