Advertisement
Guest User

Jeremiah Balongskilong

a guest
Feb 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 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 FEXER02Carpet
  8. {
  9. class Program
  10. {
  11.  
  12. public static void Main(string[] args)
  13. {
  14.  
  15. Console.Clear();
  16. double cWidth;
  17. double cLength;
  18. double cPrice;
  19. double cArea;
  20. callInstructions();
  21. cLength = cDimension("Length");
  22. cWidth = cDimension("Width");
  23. cPrice = getPrice();
  24. cArea = getArea(cWidth, cLength);
  25. callResult(cArea, cPrice);
  26. Console.Read();
  27. }
  28.  
  29. public static void callInstructions()
  30. {
  31. Console.WriteLine("This program will determine how much carpet to purchase. \nYou will be asked to enter the size of the room and the price of the carpet, in price per square yards.");
  32. }
  33.  
  34. static double cDimension(string side)
  35. {
  36. int feet, inches;
  37. Console.Write("Enter the {0} in feet: ", side);
  38. feet = int.Parse(Console.ReadLine());
  39. Console.Write("Enter the {0} in inches: ", side);
  40. inches = int.Parse(Console.ReadLine());
  41.  
  42. return (feet + (double)inches / 12);
  43. }
  44. static double getPrice()
  45. {
  46. double price;
  47.  
  48. price = double.Parse(Console.ReadLine());
  49. return price;
  50.  
  51. }
  52. static double getArea(double width, double length)
  53. {
  54. const int sfpsy = 9;
  55. double cArea = length * width / sfpsy;
  56. return cArea;
  57. }
  58.  
  59. static double dPrice(double sqY, double sqPrice)
  60. {
  61. return (sqPrice * sqY);
  62. }
  63.  
  64. static void callResult(double sqY, double sqPrice)
  65. {
  66. Console.WriteLine();
  67. Console.Write("Square Yards needed:");
  68. Console.WriteLine("{0:N2}", sqY);
  69. Console.Write("Total cost at {0:C}", sqPrice);
  70. Console.WriteLine("per Square Yard:" + "{0:C}", dPrice(sqY, sqPrice));
  71.  
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement