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

Can someone please help me with this JAVA code! ) See the \"Pack\" and \"Date\"

ID: 3835579 • Letter: C

Question

Can someone please help me with this JAVA code!

) See the "Pack" and "Date" classes. You must write the "SpecialPack" class for a Package Delivery System. A package consists of a unique, system created package ID (numeric), delivery zone (char and int pair, i.e A1 though Z9, see below for grid), the delivery date of the package (see Date class), and the package’s weight and volume (positive integers).  Packages are regular delivery (any time). SpecialPackages have a specific delivery deadline (delivered by a specific military hour 916). Use must create the "SpecialPack" subclass and include the following a. Necessary constants b. Instance variable as described above c. Nondefault constructor d. Standard accessor/mutator Methods – for the instance variable, with basic data range validation as denoted above e. toString Method Delivery Zone Grid, rows A through Z, columns 1 through 9

A1 A2 A3 A4 A5 A6 A7 A8 A9

B1 B2 B3 B4 B5 B6 B7 B8 B9

C1 C2 C3 C4 C5 C6 C7 C8 C9

. . .   . . .  

X1 X2 X3 X4 X5 X6 X7 X8 X9

Y1 Y2 Y3 Y4 Y5 Y6 Y7 Y8 Y9

Z1 Z2 Z3 Z4 Z5 Z6 Z7 Z8 Z9

these are the Date and Pack classes to use for the problem
public class Date {
private int month, day, year;
public Date( ) { setDate( 1, 1, 2000 ); }
public Date( int mm, int dd, int yyyy ) { setDate( mm, dd, yyyy ); }
public int getMonth( ) { return month; }
public int getDay( ) { return day; }
public int getYear( ) { return year; }
public void setDate( int mm, int dd, int yyyy ) {
setYear(yyyy); setMonth( mm ); setDay( dd );
}
private void setMonth( int mm ) { month = ( mm >= 1 && mm <= 12 ? mm : 1 ); }
private void setDay( int dd ) {
int [] validDays = {0,31,29,31,30,31,30,31,31,30,31,30,31};
if (!leapYear()) validDays[2]=28;
day = ( dd >= 1 && dd <= validDays[month] ? dd : 1 );
}
private void setYear( int yyyy ) { year = yyyy; }
public boolean leapYear() {
if (!((year%4==0) && ((year%100!=0)||(year%400==0)))) return false;
else return true;
}
public String toString( ) { return month + "/" + day + "/" + year; }
}
public class Pack {
private static int counter=1;
private static final int DEFAULT_WEIGHT=5;
private static final int DEFAULT_VOLUME=36;
private static final String DEFAULT_ZONE="A1";
private int packageID; private String zone;
private Date deliveryDate; int weight, volume;
public Pack(String newZone, Date newDate, int newWeight, int newVolume) {
packageID=counter; setZone(newZone); setDeliveryDate(newDate);
setWeight(newWeight); setVolume(newVolume); counter++;
}
public int getPackageID(){return packageID;}
public String getZone(){return zone;}
public void setZone(String newZone){
if (newZone.charAt(0)>='A' && newZone.charAt(0)<='Z' &&
newZone.charAt(1)>='1' && newZone.charAt(1)<='9')
zone=newZone;
else zone = DEFAULT_ZONE;
}
public Date getDeliveryDate() {
return new Date(deliveryDate.getMonth(),deliveryDate.getDay(),deliveryDate.getYear());
}
public void setDeliveryDate(Date newDate) {
deliveryDate=new Date(newDate.getMonth(),newDate.getDay(),newDate.getYear());
}
public int getWeight(){return weight;}
public void setWeight(int newWeight) {
if (newWeight>0) weight=newWeight;
else weight= DEFAULT_WEIGHT;
}
public int getVolume(){return volume;}
public void setVolume(int newVolume) {
if (newVolume>0) volume=newVolume;
else volume= DEFAULT_VOLUME;
}
public String toString() {
return packageID+" "+zone+" " +deliveryDate+" "+weight+" "+volume;
}
}

Explanation / Answer

ANSWER::


import java.util.Scanner;
public class ShippingCharge
{
public static void main (String[] args)
{
int weight = 0;   
double distance = 0.0;
double rate;
int distanceMultiplier = (int)distance / 500;   
int distanceRemainder;
Scanner input = new Scanner(System.in);   
System.out.println("What is the weight of the package (in pounds) ?");
weight = input.nextInt();
System.out.println("What is the shipping distance (in miles) ?");
distance = input.nextDouble();
distanceRemainder = (int)distance % 500;
if (distanceRemainder == 0)
{
if (weight <= 2)
System.out.println("Total Shipping Cost is: $ " + (distanceMultiplier * 1.10));
}
else if (weight > 2 && weight <= 6)
{
System.out.println("Total Shipping Cost is: $ " + (distanceMultiplier * 2.20));
}
else if (weight > 6 && weight <= 10)
{
System.out.println("Total Shipping Cost is: $ " + (distanceMultiplier * 3.70));
}
else
{
System.out.println("Total Shipping Cost is: $ " + (distanceMultiplier * 3.80));
}
if (distanceRemainder != 0)
{
if (weight <= 2)
System.out.println("Total Shipping Cost is: $ " +(distanceMultiplier + 1) * 1.10);
}
else if (weight > 2 && weight <= 6)
{
System.out.println("Total Shipping Cost is: $ " +(distanceMultiplier + 1) * 2.20);
}
else if (weight > 6 && weight <= 10)
{
System.out.println("Total Shipping Cost is: $ " +(distanceMultiplier + 1) * 3.70);
}
else
{
System.out.println("Total Shipping Cost is: $ " +(distanceMultiplier + 1) * 3.80)   
System.exit(0);
}
}

}