In Visual C# I am working on creating an application that can create both parent
ID: 3672348 • Letter: I
Question
In Visual C# I am working on creating an application that can create both parent and child classes and I think I am confuisng what needs to go in the parent class and what needs to go in the child class it must also generate a random id for each order // The package ID number is automatically assigned. //In Package class, the base delivery price is determined using the following criteria: // - Packages with weight of 32 ounces or less have a delivery fee of $5.00. // - Packages with weight of more than 32 ounces incur an extra $0.12 fee per ounce. //In InsuredPackage class, the insurance fee is calculated using the following criteria: // - Packages with value of $20.00 or less have an insurance fee of $1.00. // - Packages with a value of more than $20.00 have an insurance fee of $2.50. and must create a random ID number I can't figure out the random ID part
Explanation / Answer
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace packageevaluation { class Program { static void Main(string[] args) { Console.WriteLine("Enter the Package Weight"); double productWeightFromUser = Convert.ToDouble(Console.ReadLine()); //user defined value for Product Weight Package packageClassObj = new Package(); packageClassObj.CalculateDeliveryFees(productWeightFromUser); InsuredPackage insuredPackageObj = new InsuredPackage(); double calculatedInsuranceFees = insuredPackageObj.CalculateInsuranceFees(); string randomId = Convert.ToString(Guid.NewGuid()); // Generating a Unique Random Id Console.WriteLine("Random Id for the package weight : " + randomId); Console.WriteLine("Delivery Fees : $" + Package.deviveryFees); Console.WriteLine("Insurance Fees : $" + calculatedInsuranceFees); Console.ReadLine(); } } class Package { public static double deviveryFees; public void CalculateDeliveryFees(double productWeight) { deviveryFees = 0; try { if (productWeight > 32) { double extraWeight = productWeight - 32; deviveryFees = 5 + (extraWeight * 0.12); } else { deviveryFees = 5; // $5.00 } } catch (Exception ex) { //throw ex } } } class InsuredPackage : Package // InsuredPackage is a child class and Package is a Parent Class here { public double CalculateInsuranceFees() { double insuranceFees = 0; try { if (deviveryFeesRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.