C++ Write a program that inputs the amount of the purchase and calculates the sh
ID: 3632539 • Letter: C
Question
C++Write a program that inputs the amount of the purchase and calculates the shipping charge based on the following table:
$0.00 - $250.00: $5.00
$250.01 - $500.00: $8.00
$500.01 - $1,000.00: $10.00
$1,000.01 - $5,000.00: $15.00
over $5,000.00: $20.00
Explanation / Answer
Here you go: using System; namespace shipping { class Program { static void Main(string[] args) { double saleAmount = 0; double shipping = 0; Console.WriteLine("A program that inputs the amount of the purchase and calculates the shipping charge"); Console.Write("Enter a purchase amount to find out your shipping charges: "); string line = Console.ReadLine(); saleAmount = double.Parse(line); if (saleAmount > 5000) shipping = 20; else if (saleAmount > 1000) shipping = 15.00; else if (saleAmount > 500) shipping = 10.00; else if (saleAmount > 250) shipping = 8.00; else shipping = 5.00; Console.WriteLine(String.Format("Your merchandise in the amount of ${0:f2} will incur a shipping charge of ${1:f2}", saleAmount, shipping)); Console.Write("Press any key to exit..."); Console.ReadKey(false); } } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.