Phoenix_x

Untitled

Oct 13th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Example
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Write("Black and white or colour printing: ");
  14.             string printing = Console.ReadLine();
  15.             Console.Write("Number of books: ");
  16.             int numberOfBooks = int.Parse(Console.ReadLine());
  17.             Console.Write("Pages: ");
  18.             int pages = int.Parse(Console.ReadLine());
  19.             double grandTotal = 0;
  20.  
  21.  
  22.             switch (printing)
  23.             {
  24.                 case "black and white":
  25.                     grandTotal = blackAndWhite(numberOfBooks, pages);
  26.                     break;
  27.  
  28.                 case "colour":
  29.                     grandTotal = colourful(numberOfBooks, pages);
  30.                     break;
  31.             }
  32.  
  33.             Console.WriteLine($"Grand Total: {grandTotal:f2}");
  34.         }
  35.  
  36.         public static double blackAndWhite(int numberOfBooks, int pages)
  37.         {
  38.             double priceForASheet = 0.01;
  39.             int plate = 7;
  40.             int priceForBinding = 2;
  41.             double subtotal = (pages * plate) + ((pages / 2) * numberOfBooks) * priceForASheet + numberOfBooks * priceForBinding;
  42.             double vat = subtotal * 0.175;
  43.             double grandTotal = subtotal + vat;
  44.             return grandTotal;
  45.         }
  46.  
  47.         public static double colourful(int numberOfBooks, int pages)
  48.         {
  49.             double priceForASheet = 0.04;
  50.             double plate = 28;
  51.             double priceForBinding = 2;
  52.             double subtotal = (pages * plate) + ((pages / 2) * numberOfBooks) * priceForASheet + numberOfBooks * priceForBinding;
  53.             double vat = subtotal * 0.175;
  54.             double grandTotal = subtotal + vat;
  55.             return grandTotal;
  56.         }
  57.  
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment