Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 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 ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main()
  12. {
  13. String s1;
  14. int itemSelect;
  15. Console.Write("Enter Item number or Item");/// user inputs description "plate" or item number
  16. s1 = Console.ReadLine();
  17. int.TryParse(s1, out itemSelect);
  18. if (int.TryParse(s1, out itemSelect))/// Converts string to INT
  19. {
  20. GetDetails(itemSelect);/// pass variable to Method
  21. }
  22. else
  23. {
  24. string s2;
  25. s2 = Convert.ToString(itemSelect);
  26. GetDetails1(s2);
  27.  
  28. }
  29. }
  30.  
  31. public
  32. static void GetDetails(int entry)/// This method will display Description and Price
  33. {
  34. int[] itemNum = { 112, 123, 134, 213, 224, 235 };
  35. string[] description = { "plate", "cup", "bowl", "vase", "planter", "statue" };
  36. double[] price = { 16.95, 10.95, 14.25, 21.95, 45.99, 89.99 };
  37.  
  38. int x;
  39.  
  40.  
  41.  
  42. for (x = 0; x < itemNum.Length; ++x)
  43. {
  44. if (entry == itemNum[x])
  45. {
  46. Console.WriteLine
  47. ("Description: {0} Price: {1} ",
  48. description[x], price[x].ToString("C"));
  49.  
  50. }
  51. }
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58. public static void GetDetails1(string entry) /// for Some reason it will not pass string to this method.
  59. {
  60. int[] itemNum = { 112, 123, 134, 213, 224, 235 };
  61. string[] description = { "plate", "cup", "bowl", "vase", "planter", "statue" };
  62. double[] price = { 16.95, 10.95, 14.25, 21.95, 45.99, 89.99 };
  63.  
  64. int x;
  65.  
  66.  
  67.  
  68. for (x = 0; x < itemNum.Length; ++x)
  69. {
  70. if (entry == description[x])
  71. {
  72. Console.WriteLine
  73. ("Item:{0} Price: {1} ",
  74. itemNum[x], price[x].ToString("C"));
  75.  
  76. }
  77.  
  78.  
  79. }
  80. }
  81.  
  82.  
  83. };
  84. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement