Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace ConsoleApp1
- {
- class Program
- {
- private static List<string> householdName = new List<string>();
- private static List<double> householdIncome = new List<double>();
- private static List<double> householdMembers = new List<double>();
- private static bool repeatMain = true;
- private static bool repeatHouseHoldInfo = true;
- private static StringBuilder assistanceNeeded = new StringBuilder();
- static void Main(string[] args)
- {
- while (repeatMain)
- {
- Console.WriteLine("List of menu choices: ");
- Console.WriteLine("");
- Console.WriteLine("\t 1: Enter household information. ");
- Console.WriteLine("\t 2: Determine the assistance qualification. ");
- Console.WriteLine("\t 3: Display the household report. ");
- Console.WriteLine("\t 4: Exit the program. ");
- Console.WriteLine("");
- Console.WriteLine("Which menu choice would you like to access? ");
- var menuChoice = Int32.TryParse(Console.ReadLine(), out int result);
- if (menuChoice)
- {
- if (result == 1)
- {
- repeatHouseHoldInfo = true;
- InputHouseholdInfo();
- }
- if (result == 2)
- {
- DetermineAssistance();
- }
- if (result == 3)
- {
- DisplayHouseholdInfo();
- }
- if (result == 4)
- {
- Console.WriteLine("Thank you for using the assitance calculator. Have a great day! ");
- break;
- }
- }
- }
- /// THIS MIGHT BE CLEANER TO USE
- /// JUST DEPENDS ON WHAT YOU WANT
- //{
- // switch (result)
- // {
- // case 1:
- // repeatHouseHoldInfo = true;
- // inputHouseholdInfo();
- // break;
- // case 2:
- // //determineAssistance(householdIncome, householdMembers);
- // break;
- // case 3:
- // //displayHouseholdInfo(householdIncome, householdMembers, householdName);
- // break;
- // case 4:
- // Console.WriteLine("Thank you for using the assitance calculator. Have a great day! ");
- // break;
- // default:
- // break;
- // }
- //}
- }
- private static void InputHouseholdInfo()
- {
- while (repeatHouseHoldInfo)
- {
- Console.WriteLine("Do you have more households to enter? (yes/no) ");
- string moreInfoString = Console.ReadLine().ToLower();
- if (moreInfoString != "n" && moreInfoString != "no")
- {
- Console.WriteLine("What is the name of the family? ");
- householdName.Add(Console.ReadLine());
- Console.WriteLine("What is the income of this family?");
- var incomeParse = Double.TryParse(Console.ReadLine(), out double incomeResult);
- if (incomeParse)
- {
- householdIncome.Add(incomeResult);
- }
- Console.WriteLine("How many members are in this household?");
- var membersParse = Double.TryParse(Console.ReadLine(), out double membersResult);
- if (membersParse)
- {
- householdMembers.Add(membersResult);
- }
- }
- if (moreInfoString == "no" || moreInfoString == "n")
- {
- repeatHouseHoldInfo = false;
- }
- }
- }
- private static void DetermineAssistance()
- {
- for (int k = 0; k < householdIncome.Count; k++)
- {
- if (householdMembers[k] == 1 && householdIncome[k] > 15782)
- {
- assistanceNeeded.Append("N");
- }
- else
- {
- assistanceNeeded.Append("Y");
- }
- if ((householdIncome[k] / householdMembers[k]) >= 5618)
- {
- assistanceNeeded.Append("N");
- }
- else
- {
- assistanceNeeded.Append("Y");
- }
- }
- Console.WriteLine(assistanceNeeded.ToString());
- }
- private static void DisplayHouseholdInfo()
- {
- Console.WriteLine("Results: ");
- for (int i = 0; i < householdName.Count; i++)
- {
- Console.WriteLine($"{householdIncome[i]} {householdMembers[i]} {householdName[i]} {assistanceNeeded}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement