C# code Your mission: Write a program that gets the amount of a purchase from th
ID: 3760680 • Letter: C
Question
C# code
Your mission: Write a program that gets the amount of a purchase from the user and then calculates the shipping charge, based on the following table:
$20.00
Psuedocode
Prompt the user for the sale amount
Is sale amount greater than $5,000.00?
If so, shipping is $20.00 If not, is sale amount greater than $1,000.00?
If so, shipping is $15.00 If not, is sale amount greater than $500.00?
If so, shipping is $10.00 If not, is sale amount greater than $250.00?
If so, shipping is $8.00 If not, is sale amount greater than $0.00
shipping is $5.00 If not
shipping is $0.00
If shipping is $0.00 Display "Error incorrect input" If not Display sale amount and shipping charge
$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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleAssignments
{
class Program
{
static void Main(string[] args)
{
double salesAmt = 0;
while (salesAmt >= 0)
{
Console.WriteLine("Enter the sale amount: ");
string basestr = Console.ReadLine();
if (!Double.TryParse(basestr, out salesAmt))
Console.WriteLine("Enter valid input");
else
{
double shippingChg = 0;
if (salesAmt > 5000)
shippingChg = 20;
else if (salesAmt > 1000)
shippingChg = 15;
else if (salesAmt > 500)
shippingChg = 10;
else if (salesAmt > 250)
shippingChg = 8;
else if (salesAmt > 0)
shippingChg = 5;
else
shippingChg = 0;
if (shippingChg > 0)
Console.WriteLine("Sale Amount: " + salesAmt + " Shipping Charge: " + shippingChg);
else
Console.WriteLine("Error incorrect input");
// Console.ReadKey();
}
}
}
}
}
----------output-------------
Enter the sale amount:
5002
Sale Amount: 5002 Shipping Charge: 20
Enter the sale amount:
5000
Sale Amount: 5000 Shipping Charge: 15
Enter the sale amount:
1000
Sale Amount: 1000 Shipping Charge: 10
Enter the sale amount:
1001
Sale Amount: 1001 Shipping Charge: 15
Enter the sale amount:
500
Sale Amount: 500 Shipping Charge: 8
Enter the sale amount:
250
Sale Amount: 250 Shipping Charge: 5
Enter the sale amount:
0
Error incorrect input
Enter the sale amount:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.