Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a program for a local private delivery company that calculates the cost o

ID: 3570196 • Letter: D

Question

Design a program for a local private delivery company that calculates the cost of shipping a parcel. There are two zones A and B. The table for each zone is below:

The weight of the parcel will be a random number in the appropriate range for this program. (What does this mean?? Low: ______ High: ______)

The user specifies the zone, and the program displays the weight of the parcel, the zone, the cost per ounce and the final cost. Use the .toString method for your Parcel. Use formatted output for the weights (2 decimal places) and the costs (2 decimal places). Allow the user to reenter the zone for another parcel until the user (q)uits.

Please break this task down into appropriate modules!!

Design a program for a local private delivery company that calculates the cost of shipping a parcel. There are two zones A and B. The table for each zone is below: The weight of the parcel will be a random number in the appropriate range for this program. (What does this mean?? Low: ______ High: ______) The user specifies the zone, and the program displays the weight of the parcel, the zone, the cost per ounce and the final cost. Use the .toString method for your Parcel. Use formatted output for the weights (2 decimal places) and the costs (2 decimal places). Allow the user to reenter the zone for another parcel until the user (q)uits. Please break this task down into appropriate modules!! The main method communicates with the user Parcel class holds the data/methods about the parcel only(design!) CostTable(s) hold the cost table(s) only. Consider these tables as fairly permanent. Design! (could be a table per zone, or one (3-d!!) table for ???all??? zones... you decide) Hybrid method(s)... where do(es) it/they go?? What's a ???hybrid??? method? Calculating the cost of shipping a package concerns both the package and the cost tables... so should this method be in the Package, CostTables, or Driver class? Create a new directory for this program under your Java (or java) directory. Continue to have one file per class. The following (Linux) commands will compile the ???pieces??? and execute the program. javac Parcel.java javac CostTable.java javac Driver.java java Driver As long as all the pieces are in byte-code (compiled), all you need to run is the class with main in it! Use Server Side programming ONLY. This means interfacing with Linux and nano ONLY.

Explanation / Answer

import java.util.*;
public class TestMain {
   public static void main (String[] args){
       Scanner in = new Scanner(System.in);
   Package pf = new Package ();
   Owner of = new Owner ();
   InsuredPackage ip = new InsuredPackage ();
  
  
   int userChoice;
   boolean quit = false;
   System.out.println ("Please Enter Your Name:" );
   Owner ob1 = new Owner ();
   String name = in.nextLine();
   System.out.println ("Please Enter Your Address:" );
   Owner ob2 = new Owner ();
   String address = in.nextLine();
   System.out.println ("Owner Name is:" + name
   + " Owner Address is:" + address
   + " Unique User ID is:" + of.getOwnerID()
   + " Package number " + pf.getPackageID() + " belongs to you.");
  
   do {
   System.out.println("1. Air");
   System.out.println("2. Truck");
   System.out.println("3. Mail");
   System.out.println("0. Quit");
   System.out.print("Your choice: ");
   userChoice = in.nextInt();
  
  
  
   switch (userChoice) {
   case 1:
   System.out.println ("You have choosen to Ship by Air.");
   System.out.println ("Please enter the package weight");
  
  
   double weight = in.nextDouble();
   pf.weight = weight;
   System.out.println("Your Shipment Will Cost:" + pf.getAir());
   System.out.println("Insurance will cost" + ip.getRange());
  
     
  
  
   break;
   case 2:
   System.out.println ("You have choosen to Ship by Truck.");
   System.out.print("Please enter the package weight: ");
   pf.weight = in.nextDouble();
   System.out.println(pf.getTruck());
   System.out.println("Insurance will cost" + ip.getRange());
  
   break;
   case 3:
   System.out.println ("You have choosen to Ship by Mail.");
   System.out.print("Please enter the package weight: ");
   pf.weight = in.nextDouble();
   System.out.println(pf.getMail());
   System.out.println("Insurance will cost" + ip.getRange());
  
   break;
   case 0:
   quit = true;
   break;
  
   default:
   System.out.println("Wrong choice.");
   break;
   }
   System.out.println();
   } while (!quit);
   System.out.println("Thank you!");
   }
   
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote