Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- double discountRate = .9;
- double totalCost = 0.0;
- string itemPurchase;
- string secondaryItem;
- Console.WriteLine("Hello! Please enter the price for the first item for purchase: ");
- itemPurchase = Console.ReadLine();
- double itemPrice = Convert.ToDouble(itemPurchase);
- if (itemPrice > 50.0)
- {
- itemPrice = (itemPrice * discountRate);
- }
- else if (itemPrice < 50.0)
- {
- itemPrice = itemPrice;
- }
- else if (itemPrice < 0.0)
- {
- Console.WriteLine("I'm sorry. That is not a valid entry. Please enter a valid price.");
- itemPurchase = Console.ReadLine();
- }
- Console.WriteLine("Are there any additional items? yes/no");
- string answer = Console.ReadLine();
- do
- {
- if (answer == "yes")
- {
- Console.WriteLine("Please enter an additional item: ");
- secondaryItem = Console.ReadLine();
- double secondaryPurchase = Convert.ToDouble(secondaryItem);
- totalCost = secondaryPurchase + itemPrice;
- Console.WriteLine("Are there any additional items? yes/no");
- answer = Console.ReadLine();
- }
- else if (answer == "no")
- {
- return;
- }
- else
- {
- Console.WriteLine("This is not a valid option.");
- Console.WriteLine("Are there any additional items?");
- return;
- }
- }while (answer != "no");
- Console.WriteLine("Your total cost is: ");
- Console.Write("$");
- Console.Write(totalCost);
- Console.WriteLine();
- Console.Write("Enter any key to exit.");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement