Advertisement
Guest User

dwarfwarrior17

a guest
Jul 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace ConsoleApp1
  6. {
  7.     class Program
  8.     {
  9.         private static List<string> householdName = new List<string>();
  10.         private static List<double> householdIncome = new List<double>();
  11.         private static List<double> householdMembers = new List<double>();
  12.         private static bool repeatMain = true;
  13.         private static bool repeatHouseHoldInfo = true;
  14.         private static StringBuilder assistanceNeeded = new StringBuilder();
  15.  
  16.         static void Main(string[] args)
  17.         {
  18.             while (repeatMain)
  19.             {
  20.                 Console.WriteLine("List of menu choices: ");
  21.                 Console.WriteLine("");
  22.                 Console.WriteLine("\t 1: Enter household information. ");
  23.                 Console.WriteLine("\t 2: Determine the assistance qualification. ");
  24.                 Console.WriteLine("\t 3: Display the household report. ");
  25.                 Console.WriteLine("\t 4: Exit the program. ");
  26.                 Console.WriteLine("");
  27.                 Console.WriteLine("Which menu choice would you like to access? ");
  28.                 var menuChoice = Int32.TryParse(Console.ReadLine(), out int result);
  29.                 if (menuChoice)
  30.                 {
  31.                     if (result == 1)
  32.                     {
  33.                         repeatHouseHoldInfo = true;
  34.                         InputHouseholdInfo();
  35.                     }
  36.  
  37.                     if (result == 2)
  38.                     {
  39.                         DetermineAssistance();
  40.                     }
  41.  
  42.                     if (result == 3)
  43.                     {
  44.                         DisplayHouseholdInfo();
  45.                     }
  46.  
  47.                     if (result == 4)
  48.                     {
  49.                         Console.WriteLine("Thank you for using the assitance calculator. Have a great day! ");
  50.                         break;
  51.                     }
  52.                 }
  53.  
  54.             }
  55.  
  56.             /// THIS MIGHT BE CLEANER TO USE
  57.             /// JUST DEPENDS ON WHAT YOU WANT
  58.  
  59.             //{
  60.             //    switch (result)
  61.             //    {
  62.             //        case 1:
  63.             //            repeatHouseHoldInfo = true;
  64.             //            inputHouseholdInfo();
  65.             //            break;
  66.             //        case 2:
  67.             //            //determineAssistance(householdIncome, householdMembers);
  68.             //            break;
  69.             //        case 3:
  70.             //            //displayHouseholdInfo(householdIncome, householdMembers, householdName);
  71.             //            break;
  72.             //        case 4:
  73.             //            Console.WriteLine("Thank you for using the assitance calculator. Have a great day! ");
  74.             //            break;
  75.             //        default:
  76.             //            break;
  77.             //    }
  78.             //}
  79.  
  80.         }
  81.  
  82.         private static void InputHouseholdInfo()
  83.         {
  84.             while (repeatHouseHoldInfo)
  85.             {
  86.                 Console.WriteLine("Do you have more households to enter? (yes/no) ");
  87.                 string moreInfoString = Console.ReadLine().ToLower();
  88.  
  89.                 if (moreInfoString != "n" && moreInfoString != "no")
  90.                 {
  91.                     Console.WriteLine("What is the name of the family? ");
  92.                     householdName.Add(Console.ReadLine());
  93.  
  94.                     Console.WriteLine("What is the income of this family?");
  95.                     var incomeParse = Double.TryParse(Console.ReadLine(), out double incomeResult);
  96.                     if (incomeParse)
  97.                     {
  98.                         householdIncome.Add(incomeResult);
  99.                     }
  100.  
  101.                     Console.WriteLine("How many members are in this household?");
  102.                     var membersParse = Double.TryParse(Console.ReadLine(), out double membersResult);
  103.                     if (membersParse)
  104.                     {
  105.                         householdMembers.Add(membersResult);
  106.                     }
  107.                 }
  108.  
  109.                 if (moreInfoString == "no" || moreInfoString == "n")
  110.                 {
  111.                     repeatHouseHoldInfo = false;
  112.                 }
  113.             }
  114.         }
  115.  
  116.         private static void DetermineAssistance()
  117.         {
  118.             for (int k = 0; k < householdIncome.Count; k++)
  119.             {
  120.                 if (householdMembers[k] == 1 && householdIncome[k] > 15782)
  121.                 {
  122.                     assistanceNeeded.Append("N");
  123.  
  124.                 }
  125.                 else
  126.                 {
  127.                     assistanceNeeded.Append("Y");
  128.                 }
  129.  
  130.                 if ((householdIncome[k] / householdMembers[k]) >= 5618)
  131.                 {
  132.                     assistanceNeeded.Append("N");
  133.                 }
  134.                 else
  135.                 {
  136.                     assistanceNeeded.Append("Y");
  137.                 }
  138.  
  139.             }
  140.  
  141.             Console.WriteLine(assistanceNeeded.ToString());
  142.         }
  143.  
  144.         private static void DisplayHouseholdInfo()
  145.         {
  146.             Console.WriteLine("Results: ");
  147.             for (int i = 0; i < householdName.Count; i++)
  148.             {
  149.                 Console.WriteLine($"{householdIncome[i]} {householdMembers[i]} {householdName[i]} {assistanceNeeded}");
  150.             }
  151.         }
  152.  
  153.     }
  154.  
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement