Here are 3 different programs. I have seen similar variations online, but none that could help these specific issues I am having. I am going off a template our professor provided. Having a hard time grasping his specific verbiage. Specifically towards the end of the package and insured package files. In the InsuredPackage file, my if-else conditions keep telling me to remove/add the ()'s. And am not sure how to edit it correctly. At the end of Package and InsuredPackage, there is an "increasedCost(i);" but not sure why my professor added it to the template, and it seems unnecessary. Any feedback will be greatly appreciated. public class Package{ // declare Package class attribute variables private int weight; private char deliverType; private double cost; final char AIR = 'A'; final char TRUCK = 'T'; final char MAIL = 'M'; // constants for the first row costs depending on the shipping method final int LOWWT = 8; // weight limit for first row in the table for the package weights less than 8 final double LOWAIR = 2.00; final double LOWTRUCK = 1.50; final double LOWMAIL = .50; final int MEDWT = 16; //weight limit for second row in the table - the row applies when the package weight is lower than 17, but greater than 3 final double MEDAIR = 3.50; final double MEDTRUCK = 2.75; final double MEDMAIL = 1.50; // shipping costs for third row in the table - the row applies when the package weight is greater than 17 final double HIGHAIR = 4.75; final double HIGHTRUCK = 3.50; final double HIGHMAIL = 2.25; //overload constructor public Package(int w, char d) { Package Package1 = new Package(int w, char d); Package Package2 = new Package(int w, char d); weight = w; } // create calculateCost method which will be called by the constructor above - add the // shipping cost value depending on provided weight and shipping option data. private double cost(int w, char d) { double c; //if-else statements to determine weight and claculateCost cost = c; if(w <= LOWWT) { if (d == AIR){ c = LOWAIR; else if (d == TRUCK) c = LOWTRUCK; else (d == MAIL) c = LOWMAIL;} else if (w <= MEDWT && w > LOWWT) { c = MEDAIR; else if (d == TRUCK) c = MEDTRUCK; else (d == MAIL) c = MEDMAIL;} else (d == AIR){ c = HIGHAIR; else if (d == TRUCK) c = HIGHTRUCK; else (d == MAIL) c == HIGHMAIL; } } return c; } // Display method prints out the weight, delivery type, and claculateCost. public void display() { System.out.println("The package weight is: " + weight + "(oz)\nThe Package delivery method is : " + deliverType); System.out.println("The cost of delivery" , + calculateCost); } } //method returns the the getCost to me used in the next program public double getCost() { return c = new getCost; } //the method to add the c/getCost and the insType public void insType(double c) { increaseCost = new c + new insType; } } //--second program-- public class InsuredPackage extends Package{ InsuredPackage(int w, char d, char it){ super(w,d);//call the superclass constructor char insType = it; //'S' for standard insurance, 'P' for premium insurance //defines the insurance costs final double LOWCOST = 3.00; final double MEDCOST = 10.0; final double LOWINS = 0.0; final double MEDINS = 5.0; final double HIGHINS = 10; final double LOWPREMINS = 0.0; final double MEDPREMINS = 10.0; final double HIGHPREMINS = 15.0; double i = 0.0; //using if else to determine which insurance based on the getCost/delivery method if(getCost() <= LOWCOST){ if (it = 'S') { i = LOWINS;} else (it = 'P'){ i = LOWPREMINS; } else if (getCost() <= MEDCOST){ if (it = 'S'){ i = MEDINS;} else { i = MEDPREMINS; } } else { if (it = 'S'){ i = HIGHINS;} else { i = HIGHPREMINS;} return i; //Print insurance statement System.out.println("Insurance fee is: "+ i); } insurancCost(i); } } } //-----third program-- public class ShipPackage extends InsuredPackage{//inherits the InsuredPackage class methods ShipPackage(int weight, char deliverType){ super(weight,deliverType);//call the superclass constructor } public static void ShipPackage(String args[]){ //declares the package based on the input in the (*,*,*) Package p1 = new Package(4, 'A'); Package p2 = new Package(22, 'M'); InsuredPackage p1 = new InsuredPackage(10, 'A', 'P'); InsuredPackage p2 = new InsuredPackage(10, 'T', 'S'); } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Here are 3 different programs. I have seen similar variations online, but none that could help these specific issues I am having. I am going off a template our professor provided. Having a hard time grasping his specific verbiage. Specifically towards the end of the package and insured package files. In the InsuredPackage file, my if-else conditions keep telling me to remove/add the ()'s. And am not sure how to edit it correctly. At the end of Package and InsuredPackage, there is an "increasedCost(i);" but not sure why my professor added it to the template, and it seems unnecessary. Any feedback will be greatly appreciated.

public class Package{

// declare Package class attribute variables
private int weight;
private char deliverType;
private double cost;

final char AIR = 'A';
final char TRUCK = 'T';
final char MAIL = 'M';

// constants for the first row costs depending on the shipping method
final int LOWWT = 8; // weight limit for first row in the table for the package weights less than 8
final double LOWAIR = 2.00;
final double LOWTRUCK = 1.50;
final double LOWMAIL = .50;

final int MEDWT = 16; //weight limit for second row in the table - the row applies when the package weight is lower than 17, but greater than 3
final double MEDAIR = 3.50;
final double MEDTRUCK = 2.75;
final double MEDMAIL = 1.50;

// shipping costs for third row in the table - the row applies when the package weight is greater than 17
final double HIGHAIR = 4.75;
final double HIGHTRUCK = 3.50;
final double HIGHMAIL = 2.25;

//overload constructor
public Package(int w, char d) {
Package Package1 = new Package(int w, char d);
Package Package2 = new Package(int w, char d);

weight = w;

}

// create calculateCost method which will be called by the constructor above - add the
// shipping cost value depending on provided weight and shipping option data.
private double cost(int w, char d)
{
double c; //if-else statements to determine weight and claculateCost
cost = c;

if(w <= LOWWT)
{
if (d == AIR){
c = LOWAIR;
else if (d == TRUCK)
c = LOWTRUCK;
else (d == MAIL)
c = LOWMAIL;}
else if (w <= MEDWT && w > LOWWT) {
c = MEDAIR;
else if (d == TRUCK)
c = MEDTRUCK;
else (d == MAIL)
c = MEDMAIL;}
else (d == AIR){
c = HIGHAIR;
else if (d == TRUCK)
c = HIGHTRUCK;
else (d == MAIL)
c == HIGHMAIL;
}
}
return c;
}


// Display method prints out the weight, delivery type, and claculateCost.
public void display()
{
System.out.println("The package weight is: " + weight + "(oz)\nThe Package delivery method is : " + deliverType);
System.out.println("The cost of delivery" , + calculateCost);
}
}
//method returns the the getCost to me used in the next program
public double getCost() {
return c = new getCost;
}

//the method to add the c/getCost and the insType
public void insType(double c)
{

increaseCost = new c + new insType;
}
}

//--second program--

public class InsuredPackage extends Package{

InsuredPackage(int w, char d, char it){

super(w,d);//call the superclass constructor
char insType = it; //'S' for standard insurance, 'P' for premium insurance

//defines the insurance costs
final double LOWCOST = 3.00;
final double MEDCOST = 10.0;

final double LOWINS = 0.0;
final double MEDINS = 5.0;
final double HIGHINS = 10;

final double LOWPREMINS = 0.0;
final double MEDPREMINS = 10.0;
final double HIGHPREMINS = 15.0;

double i = 0.0;

//using if else to determine which insurance based on the getCost/delivery method
if(getCost() <= LOWCOST){
if (it = 'S') {
i = LOWINS;}
else (it = 'P'){
i = LOWPREMINS;
}

else if (getCost() <= MEDCOST){
if (it = 'S'){
i = MEDINS;}
else {
i = MEDPREMINS;
}
}
else {
if (it = 'S'){
i = HIGHINS;}
else {
i = HIGHPREMINS;}
return i;
//Print insurance statement
System.out.println("Insurance fee is: "+ i);

}
insurancCost(i);

}
}
}

//-----third program--


public class ShipPackage extends InsuredPackage{//inherits the InsuredPackage class methods

ShipPackage(int weight, char deliverType){

super(weight,deliverType);//call the superclass constructor
}
public static void ShipPackage(String args[]){

//declares the package based on the input in the (*,*,*)
Package p1 = new Package(4, 'A');
Package p2 = new Package(22, 'M');
InsuredPackage p1 = new InsuredPackage(10, 'A', 'P');
InsuredPackage p2 = new InsuredPackage(10, 'T', 'S');


}
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 7 images

Blurred answer
Knowledge Booster
Fundamentals of Testing Strategies
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education