- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ShippingRateCalculator
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numPackages;
- double packageHeight, packageLength, packageWidth, packageVolume, packagePerimeter, packageWeight, total = 0, extraCharges = 0;
- string shippingType;
- bool air = false;
- //Some of these things I am not sure how to write into methods. I also think some of the methods are really cluttered and could be written better, but I'm not sure how.
- //Do not know how to write a restraint method. Have not written the summary stuff yet, since I think it will change when I talk to you
- Console.WriteLine("How many packages would you like to ship?");
- numPackages = Convert.ToInt32(Console.ReadLine());
- //Package information. Do not know how to do this in a method. Was thinking it would be ok with a for loop, but I can't think of a way to write it.
- Console.WriteLine("What is the height of the package?");
- packageHeight = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("What is the length of the package?");
- packageLength = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("What is the width of the package?");
- packageWidth = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("How much does the package weigh?");
- packageWeight = Convert.ToDouble(Console.ReadLine());
- //Shipping information
- Console.WriteLine("Is this package being sent by air or land?");
- shippingType = Console.ReadLine();
- if (shippingType == "air")
- {
- air = true;
- }
- //Dimension methods
- packagePerimeter = Perimeter(packageLength, packageWidth);
- packageVolume = Volume(packageHeight, packageWidth, packageLength);
- //Surcharge method
- extraCharges = Surcharges(packageWeight, packageVolume, packagePerimeter, air);
- total += extraCharges;
- }
- public static double Volume(double height, double width, double length)
- {
- double total = 0;
- total = height * width * length;
- return total;
- }
- public static double Perimeter(double length, double width)
- {
- double total = 0;
- total = (2 * length) + (2 * width);
- return total;
- }
- public static double Surcharges(double weight, double volume, double perimeter, bool air)
- {
- double total = 0;
- const double FLAT_RATE = 4.95, SM_WEIGHT = 3.95, MD_WEIGHT = 6.95, LG_WEIGHT = 9.95, LG_VOL = 5.95, LG_PERIMETER = 3.95, AIR_SHIP = 9.95;
- total += FLAT_RATE;
- if (weight >= 10 && weight < 15)
- {
- total += SM_WEIGHT;
- }
- else if (weight >= 15 && weight <= 20 )
- {
- total += MD_WEIGHT;
- }
- else if (weight >= 20 && weight <= 25 )
- {
- total += LG_WEIGHT;
- }
- if (volume > 4800)
- {
- total += LG_VOL;
- }
- if (perimeter > 130)
- {
- total += LG_PERIMETER;
- }
- if (air == true)
- {
- total += AIR_SHIP;
- }
- return total;
- }
- }
- }