Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Purpose: To calculate the shipping costs based on charge and items purchased.
- * Dev: Drennen Dooms
- * Date: 3/31/2015
- */
- using System;
- namespace PurchasesApp
- {
- class PurchasesClass
- {
- //data fields
- private decimal theCost;
- private int thePurchased;
- //properties
- public decimal Cost
- {
- get { return theCost; }
- set { theCost = value; }
- }
- public int Purchased
- {
- get { return thePurchased; }
- set { thePurchased = value; }
- }
- //constructors
- public PurchasesClass()
- {
- }
- //constructor with 2 args
- public PurchasesClass(decimal cost, int purchased)
- {
- theCost = cost;
- thePurchased = purchased;
- }
- //methods
- //method to calculate shipping
- public decimal GetShipping()
- {
- decimal myCost = 0.00M;
- if(thePurchased < 3)
- { myCost = 3.50M; }
- else
- if(thePurchased >= 3 && thePurchased <= 6)
- { myCost = 5.00M; }
- else
- if(thePurchased >= 5 && thePurchased <= 12)
- { myCost = 7.00M; }
- else
- if(thePurchased >= 11 && thePurchased <= 15)
- { myCost = 9.00M; }
- else
- if(thePurchased > 15)
- { myCost = 10.00M; }
- return myCost;
- }
- //calculate tax
- public decimal GetTax()
- {
- decimal taxAmount = 0.0775M;
- decimal taxed;
- taxed = theCost * taxAmount;
- return taxed;
- }
- //calculate total
- public decimal GetTotal()
- {
- decimal total;
- total = GetTax() + GetShipping();
- return total;
- }
- //Send data in string
- public override string ToString()
- {
- return "\tShipping Calculator App" +
- "\n\nShipping with tax: " + GetTotal().ToString("C");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement