Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Test
  4. {
  5. class Program
  6. {
  7. private static string[] householdName = new string[100];
  8. private static double[] householdIncome = new double[100];
  9. private static double[] householdMembers = new double[100];
  10.  
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("List of menu choices: ");
  14. Console.WriteLine("");
  15. Console.WriteLine("\t 1: Enter household information. ");
  16. Console.WriteLine("\t 2: Determine the assistance qualification. ");
  17. Console.WriteLine("\t 3: Display the household report. ");
  18. Console.WriteLine("\t 4: Exit the program. ");
  19. Console.WriteLine("");
  20. Console.WriteLine("Which menu choice would you like to access? ");
  21. Double menuChoice = Double.Parse(Console.ReadLine());
  22.  
  23. while (menuChoice == 1)
  24. {
  25. inputHouseholdInfo();
  26. }
  27.  
  28. while (menuChoice == 2)
  29. {
  30. determineAssistance(householdIncome, householdMembers);
  31. }
  32.  
  33. while (menuChoice == 3)
  34. {
  35. displayHouseholdInfo(householdIncome, householdMembers, householdName);
  36. }
  37.  
  38. while (menuChoice == 4)
  39. {
  40. Console.WriteLine("Thank you for using the assitance calculator. Have a great day! ");
  41. break;
  42. }
  43.  
  44. }
  45.  
  46. private static void inputHouseholdInfo()
  47. {
  48.  
  49. Console.WriteLine("Do you have more households to enter? (yes/no) ");
  50. string moreInfo = Console.ReadLine();
  51. string moreInfoString = moreInfo.ToLower();
  52.  
  53. while (moreInfoString != "n" && moreInfoString != "no") {
  54.  
  55. for (int counter = 0; counter < householdName.Length; counter++)
  56. {
  57.  
  58. Console.WriteLine("What is the name of the family? ");
  59. householdName[counter] = Console.ReadLine();
  60.  
  61. Console.WriteLine("What is the income of this family?");
  62. householdIncome[counter] = Double.Parse(Console.ReadLine());
  63.  
  64. Console.WriteLine("How many members are in this household?");
  65. householdMembers[counter] = Double.Parse(Console.ReadLine());
  66.  
  67. return;
  68.  
  69. }
  70.  
  71. break;
  72.  
  73. }
  74.  
  75. }
  76.  
  77. private static string determineAssistance(Double[] householdIncome, Double[] householdMembers)
  78. {
  79. string assistanceNeeded = "";
  80.  
  81. for (int k = 0; k < householdIncome.Length; k++)
  82. {
  83. if (householdMembers[k] == 1 && householdIncome[k] > 15782)
  84. {
  85. assistanceNeeded = "N";
  86.  
  87. }
  88. else
  89. {
  90. assistanceNeeded = "Y";
  91. return String.Concat(assistanceNeeded);
  92.  
  93. }
  94.  
  95. if ((householdIncome[k] / householdMembers[k]) >= 5618)
  96. {
  97. assistanceNeeded = "N";
  98.  
  99. }
  100. else
  101. {
  102. assistanceNeeded = "Y";
  103. return String.Concat(assistanceNeeded);
  104.  
  105. }
  106.  
  107. }
  108.  
  109. return String.Concat(assistanceNeeded);
  110.  
  111. }
  112.  
  113. private static void displayHouseholdInfo(double[] householdIncome, double[] householdMembers, string[] householdName)
  114. {
  115. Console.WriteLine("Results: ");
  116. Console.WriteLine(String.Format("{0} {1} {2}", householdIncome, householdMembers, householdName));
  117. }
  118.  
  119. }
  120.  
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement