Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 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(string[] args)
  12. {
  13. double discountRate = .9;
  14. double totalCost = 0.0;
  15. string itemPurchase;
  16. string secondaryItem;
  17. Console.WriteLine("Hello! Please enter the price for the first item for purchase: ");
  18. itemPurchase = Console.ReadLine();
  19. double itemPrice = Convert.ToDouble(itemPurchase);
  20. if (itemPrice > 50.0)
  21. {
  22. itemPrice = (itemPrice * discountRate);
  23. }
  24. else if (itemPrice < 50.0)
  25. {
  26. itemPrice = itemPrice;
  27. }
  28. else if (itemPrice < 0.0)
  29. {
  30. Console.WriteLine("I'm sorry. That is not a valid entry. Please enter a valid price.");
  31. itemPurchase = Console.ReadLine();
  32. }
  33. Console.WriteLine("Are there any additional items? yes/no");
  34. string answer = Console.ReadLine();
  35. do
  36. {
  37. if (answer == "yes")
  38. {
  39. Console.WriteLine("Please enter an additional item: ");
  40. secondaryItem = Console.ReadLine();
  41. double secondaryPurchase = Convert.ToDouble(secondaryItem);
  42. totalCost = secondaryPurchase + itemPrice;
  43. Console.WriteLine("Are there any additional items? yes/no");
  44. answer = Console.ReadLine();
  45.  
  46. }
  47. else if (answer == "no")
  48. {
  49. return;
  50. }
  51. else
  52. {
  53. Console.WriteLine("This is not a valid option.");
  54. Console.WriteLine("Are there any additional items?");
  55. return;
  56. }
  57. }while (answer != "no");
  58. Console.WriteLine("Your total cost is: ");
  59. Console.Write("$");
  60. Console.Write(totalCost);
  61. Console.WriteLine();
  62. Console.Write("Enter any key to exit.");
  63. Console.ReadKey();
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement