Want more features on Pastebin? Sign Up, it's FREE!
Guest

Account Executive Program

By: wis3_guy on Feb 13th, 2013  |  syntax: None  |  size: 5.98 KB  |  views: 540  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace applicationName
  8. {
  9.    public class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //Declare new lists based on the discounts each customer will receive
  14.             CustomerGroup noDiscountCg = new CustomerGroup();
  15.             CustomerGroup lowDiscountCg = new CustomerGroup();
  16.             CustomerGroup highDiscountCg = new CustomerGroup();
  17.  
  18.             List<Customer> unsortedCustomer = new List<Customer>();
  19.  
  20.             //Adding customers to the unsorted list
  21.             unsortedCustomer.Add(new Customer(123456, "Thom Yorke", "215 Chestnut Lane", "thomyorke@radiohead.com", 2569876548, new DateTime(2013, 1, 9), 500));
  22.             unsortedCustomer.Add(new Customer(852963, "Annie Clark", "879 Hickory Road", "annieclark@gmail.com", 3135453404, new DateTime(2002, 11, 12), 200));
  23.             unsortedCustomer.Add(new Customer(147987, "Claire Boucher", "200 Dogwood Drive", "claireboucher@gmail.com", 9635874102, new DateTime(2000, 10, 11), 10));
  24.             unsortedCustomer.Add(new Customer(357951, "Sophie Hutchings", "963 Highview Court", "sophiehutchings@gmail.com", 2510147756, new DateTime(2007, 8, 8), 400));
  25.             unsortedCustomer.Add(new Customer(789987, "Danny Teague", "8410 Greensboro Road ", "teague@gmail.com", 2315648974, new DateTime(2011, 4, 4), 60));
  26.             unsortedCustomer.Add(new Customer(753963, "Brian McBride", "444 Buena Vista Court", "brianmcbride1@gmail.com", 7899877410, new DateTime(2003, 10, 10), 560));
  27.             unsortedCustomer.Add(new Customer(200132, "David Bowie", "921 Washington Ave", "davidbowie@gmail.com", 4566541230, new DateTime(2000, 1, 1), 910));
  28.             unsortedCustomer.Add(new Customer(452631, "Aidan Baker", "741 Palm Springs Road", "abaker@gmail.com", 1233210123, new DateTime(2005, 5, 5), 700));
  29.             unsortedCustomer.Add(new Customer(687952, "Ben Frost", "563 Cedar Lane", "benfrost@gmail.com", 8256987654, new DateTime(2013, 2, 9), 890));
  30.             unsortedCustomer.Add(new Customer(985204, "Bill Laswell", "10 Pennsylvania Ave", "blaswell@gmail.com", 3413545340, new DateTime(2004, 12, 12), 201));
  31.             unsortedCustomer.Add(new Customer(002154, "Claude Debussy", "852 Stone Brook Road", "cdebussy@gmail.com", 5874963102, new DateTime(2001, 2, 5), 101));
  32.             unsortedCustomer.Add(new Customer(311159, "James Blake", "700 Mountain View Drive", "jamesblake@gmail.com", 2477510156, new DateTime(2007, 7, 3), 630));
  33.            
  34.             //Loop that sorts based on discounts given number of average transactions
  35.             //Assigns each unsorted customer into a new group based on the discount they'll receive
  36.             foreach (Customer temporary in unsortedCustomer)
  37.             {
  38.                 if (temporary.CalcTransaction() <= 3)
  39.                 {
  40.                     noDiscountCg.CustomerList.Add(temporary);
  41.                 }
  42.  
  43.                 if (temporary.CalcTransaction() > 6)
  44.  
  45.                 {
  46.                     lowDiscountCg.CustomerList.Add(temporary);
  47.                 }
  48.  
  49.                 if (temporary.CalcTransaction() > 15)
  50.                 {
  51.                     highDiscountCg.CustomerList.Add(temporary);
  52.                 }
  53.             }
  54.  
  55.             //Assign unique ID's to each customer group
  56.  
  57.             noDiscountCg.GroupID = 200;
  58.             lowDiscountCg.GroupID = 500;
  59.             highDiscountCg.GroupID = 700;
  60.            
  61.             FileStream ostrm;
  62.             StreamWriter writer;
  63.             TextWriter oldOut = Console.Out;
  64.             try
  65.             {
  66.                 ostrm = new FileStream("./sorted_customer_list.txt", FileMode.OpenOrCreate, FileAccess.Write);
  67.                 writer = new StreamWriter(ostrm);
  68.             }
  69.             catch (Exception e)
  70.             {
  71.                 Console.WriteLine("Cannot open sorted_customer_list.txt for writing");
  72.                 Console.WriteLine(e.Message);
  73.                 return;
  74.             }
  75.             Console.SetOut(writer);
  76.            
  77.  
  78.         //Assign account executive to each group
  79.             noDiscountCg.AccountExecutive.Name = "Robert Rich";
  80.             Console.WriteLine("The following customers will be assigned to the account executive named " + noDiscountCg.AccountExecutive.Name);
  81.             Console.WriteLine("This customer will be placed in group number " + noDiscountCg.GroupID);
  82.             foreach (Customer Customer in noDiscountCg.CustomerList)
  83.               {
  84.                   Console.WriteLine(Customer.Name);
  85.                   Console.WriteLine(Customer.TotalTransactions);
  86.               }
  87.  
  88.             lowDiscountCg.AccountExecutive.Name = "Brian Williams";
  89.             Console.WriteLine("The following customers will be assigned to the account executive named " + lowDiscountCg.AccountExecutive.Name);
  90.             Console.WriteLine("This customer will be placed in group number " + lowDiscountCg.GroupID);
  91.             foreach (Customer Customer in lowDiscountCg.CustomerList)
  92.               {
  93.                 Console.WriteLine(Customer.Name);
  94.                 Console.WriteLine(Customer.TotalTransactions);
  95.               }
  96.  
  97.             highDiscountCg.AccountExecutive.Name = "Tim Hecker";
  98.             Console.WriteLine("The following customers will be assigned to the account executive named " + highDiscountCg.AccountExecutive.Name);
  99.             Console.WriteLine("This customer will be placed in group number " + highDiscountCg.GroupID);
  100.              foreach (Customer Customer in highDiscountCg.CustomerList)
  101.               {
  102.                   Console.WriteLine(Customer.Name);
  103.                   Console.WriteLine(Customer.TotalTransactions);
  104.               }
  105.            
  106.              Console.SetOut(oldOut);
  107.              writer.Close();
  108.              ostrm.Close();
  109.              Console.WriteLine("Done.");
  110.              Console.WriteLine("This text file is located in the Debug subfolder within the Bin folder.");
  111.            
  112.         }
  113.     }
  114. }
clone this paste RAW Paste Data