Question
in my C# console program I am having troubles with the following; In this snippet, it tells me that this represents a boolean and is
in my C# console program I am having troubles with the following;
In this snippet, it tells me that this represents a boolean and is an invalid expression
else if (orderTotal >= 50 && < 100) shippingAmount = 4.99;
In the following calculation, it tells me that my variables are unassigned, but they do not show that earlier in the code.
grandTotal = ((orderTotal * tax) + shippingAmount);
Here is what my prgram is supposed to do;
Assume that you've started a business that sells sporting goods equipment online. You currently have operations in Arizona and California. As such, you only need to charge tax if the order comes from one of these states. Assume the tax rate is 10% for California and 5% for Arizona. You also need to charge for shipping. You charge a flat rate of $12.99 for orders less than $50 and a rate of $4.99 for orders between $50 and $100. You do not charge shipping for orders $100 and over.
I have included my code below.
//start code
using System; using static System.Console;
namespace ConsoleApp2 { class Program
{
static void Main(string[] args) { double shippingAmount; double tax; string stateAbbrev; double grandTotal;
//enter order amount WriteLine("Enter order amount"); WriteLine(); double orderTotal = Convert.ToDouble(Console.ReadLine()); Console.ReadLine();
//enter state and set tax amount WriteLine("Enter the state abbreviation (AZ or CA)."); WriteLine("Its full name will" + " be displayed."); WriteLine(); stateAbbrev = ReadLine(); switch (stateAbbrev) { //AZ sales tax case "AZ": WriteLine("Arizona tax is 5%."); tax = 1.05; break;
//CAsales tax case "CA": WriteLine("California tax is 10%"); tax = 1.10; break; //error message default: WriteLine("No match"); break;
} //Calculate shipping if (orderTotal < 50) shippingAmount = 12.99;
else if (orderTotal >= 50 && < 100) shippingAmount = 4.99;
else if (orderTotal >= 100) shippingAmount = 0;
WriteLine("Grand total is " + "{0:0.00}", orderTotal);
ReadKey();
} } }
//end code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started