using System;
class Program
{
static void Main()
{
double total_Shipping = 0, total_Weight, standard_Item = 3.00, express_Item = 4.00, over_Night_Item = 5.50, standard_Weight = 1.45, express_Weight = 2.50, over_Night_Weight = 3.00, rate = 0, surcharge_Standard = 2.50, surcharge_Express = 5.00, surcharge_OverNight = 8.00;
int shipping_Speed, total_Items = 0;
char shipping_Type, hawaii;
Console.WriteLine("Please enter which shipping method you want:");
Console.WriteLine("Enter 1- for Standard shipping.");
Console.WriteLine("Enter 2- for Express shipping.");
Console.WriteLine("Enter 3- for Overnight shipping.");
shipping_Speed = int.Parse(Console.ReadLine());
Console.WriteLine("Thank you.");
Console.WriteLine("Is this shipment in category A or B?");
shipping_Type = char.Parse(Console.ReadLine());
Console.WriteLine("Thank you.");
Console.WriteLine("Will this package be shipped to Alaska or Hawaii?(Y/N)");
hawaii = char.Parse(Console.ReadLine());
Console.WriteLine("Thank you.");
if (shipping_Type == 1)
{
Console.WriteLine("How many items are to be shipped?");
total_Items = (int)(Console.Read());
}
else if (shipping_Type == 2)
Console.WriteLine("How heavy is your package?(In pounds)");
total_Weight = double.Parse(Console.ReadLine());
if (shipping_Speed == 1 && shipping_Type == 'a')
{
rate = standard_Item;
}
else if (shipping_Speed == 1 && shipping_Type == 'b')
{
rate = standard_Weight;
}
else if (shipping_Speed == 2 && shipping_Type == 'a')
{
rate = express_Item;
}
else if (shipping_Speed == 2 && shipping_Type == 'b')
{
rate = express_Weight;
}
else if (shipping_Speed == 3 && shipping_Type == 'a')
{
rate = over_Night_Item;
}
else if (shipping_Speed == 3 && shipping_Type == 'b')
{
rate = over_Night_Weight;
}
if (shipping_Speed == 1 && shipping_Type == 'a' && hawaii == 'y')
{
total_Shipping = rate * total_Items + surcharge_Standard;
}
else if (shipping_Speed == 1 && shipping_Type == 'a' && hawaii == 'n')
{
total_Shipping = rate * total_Items;
}
else if (shipping_Speed == 1 && shipping_Type == 'a' && hawaii == 'y')
{
total_Shipping = rate * total_Weight + surcharge_Standard;
}
else if (shipping_Speed == 1 && shipping_Type == 'b' && hawaii == 'n')
{
total_Shipping = rate * total_Weight;
}
else if (shipping_Speed == 2 && shipping_Type == 'a' && hawaii == 'y')
{
total_Shipping = rate * total_Items + surcharge_Express;
}
else if (shipping_Speed == 2 && shipping_Type == 'a' && hawaii == 'n')
{
total_Shipping = rate * total_Items;
}
else if (shipping_Speed == 2 && shipping_Type == 'b' && hawaii == 'a')
{
total_Shipping = rate * total_Weight + surcharge_Express;
}
else if (shipping_Speed == 2 && shipping_Type == 'b' && hawaii == 'n')
{
total_Shipping = rate * total_Weight;
}
else if (shipping_Speed == 3 && shipping_Type == 'a' && hawaii == 'y')
{
total_Shipping = rate * total_Items + surcharge_OverNight;
}
else if (shipping_Speed == 3 && shipping_Type == 'a' && hawaii == 'n')
{
total_Shipping = rate * total_Items;
}
else if (shipping_Speed == 3 && shipping_Type == 'b' && hawaii == 'y')
{
total_Shipping = rate * total_Weight + surcharge_OverNight;
}
else if (shipping_Speed == 3 && shipping_Type == 'b' && hawaii == 'n')
{
total_Shipping = rate * total_Weight;
}
if (shipping_Speed == 1) Console.WriteLine("Standard Shipping");
else if (shipping_Speed == 2) Console.WriteLine("Express Shipping");
else if (shipping_Speed == 3) Console.WriteLine("Over-Night Shipping");
if (shipping_Type == 1)
Console.WriteLine ("{0}", total_Items);
else if (shipping_Type == 2)
Console.WriteLine ("{0}", total_Weight);
Console.WriteLine("Total shipping costs: {0:$}", total_Shipping);
Console.WriteLine("Thank you for shopping at Red Fern On-Line Electronics!");
Console.WriteLine("Press any key to continue...");
Console.ReadLine();
HiImBen
0
Newbie Poster
Recommended Answers
Jump to PostWhat doesn't work about it?
Also please enclose your code in code tags:
[code]
//code goes here
[/code]
There's still a few minutes left on your editing time for it.
Jump to PostHint: shipping type is a character, it's not likely to be equal to 1 in this context. In a similar vein, Console.Read() reads in a character and returns the code for that character (so if you put in 10 it would return the ascii code for 1 which is 49). …
Jump to Postwhy the heck you created a console app?
Because that is the general learning curve.
Jump to PostAlso, look at using int.TryParse rather than Parse. TryParse will copy the value to an output variable and returns a boolean value to show wether the parse succeeded. int.Parse will throw an exception if the user doesnt enter a valid number.
Console.WriteLine("Please enter which shipping method you …
All 13 Replies
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
asprin
14
Newbie Poster
apegram
302
LINQ!
Team Colleague
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
serkan sendur 6
0
Newbie Poster
Banned
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
kplcjl
17
Junior Poster
kplcjl
17
Junior Poster
kplcjl
17
Junior Poster
jonsca
1,059
Quantitative Phrenologist
Team Colleague
Featured Poster
Geekitygeek
480
Nearly a Posting Virtuoso
kplcjl
17
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.