In: Computer Science
Define a JAVA class ISP. The class consists of the name of the
subscription plan and a
method that display the plan. Derive a class DPlan from ISP. The
DPlan will charge
RM10 per Mbps subscribe and RM0.20 per GB used. Derive a class
MPlan from ISP.
The MPlan will charge RM5 per Mbps subscribe and RM0.80 per GB
used. Display
the plan and select the best plan.
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
// ISP.java
public class ISP {
   private String subscriptionPlan;
   /**
   * @param subscriptionPlan
   */
   public ISP(String subscriptionPlan) {
       this.subscriptionPlan =
subscriptionPlan;
   }
   /**
   * @return the subscriptionPlan
   */
   public String getSubscriptionPlan() {
       return subscriptionPlan;
   }
   /**
   * @param subscriptionPlan
   * the subscriptionPlan to set
   */
   public void setSubscriptionPlan(String
subscriptionPlan) {
       this.subscriptionPlan =
subscriptionPlan;
   }
   /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#toString()
   */
   @Override
   public String toString() {
       return "Subscription Plan = " +
subscriptionPlan;
   }
}
===========================================

===========================================
// DPlan.java
public class DPlan extends ISP {
   private double mbps;
   private double GBUsed;
   /**
   * @param subscriptionPlan
   * @param mbps
   * @param gBUsed
   */
   public DPlan(String subscriptionPlan, double mbps,
double GBUsed) {
       super(subscriptionPlan);
       this.mbps = mbps;
       this.GBUsed = GBUsed;
   }
   /**
   * @return the mbps
   */
   public double getMbps() {
       return mbps;
   }
   /**
   * @param mbps
   * the mbps to set
   */
   public void setMbps(double mbps) {
       this.mbps = mbps;
   }
   /**
   * @return the gBUsed
   */
   public double getGBUsed() {
       return GBUsed;
   }
   /**
   * @param gBUsed
   * the gBUsed to set
   */
   public void setGBUsed(double gBUsed) {
       GBUsed = gBUsed;
   }
   public double totalCost() {
       double price = 0.0;
       price = mbps * 10 + GBUsed *
0.20;
       return price;
   }
   /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#toString()
   */
   @Override
   public String toString() {
       return super.toString() + "\nMbps =
" + mbps + "\nGBUsed = " + GBUsed
          
    + "\nTotal Price :$" + totalCost();
   }
}
===========================================


===========================================
// MPlan.java
public class MPlan extends ISP {
   private double mbps;
   private double GBUsed;
   /**
   * @param subscriptionPlan
   * @param mbps
   * @param gBUsed
   */
   public MPlan(String subscriptionPlan, double mbps,
double GBUsed) {
       super(subscriptionPlan);
       this.mbps = mbps;
       this.GBUsed = GBUsed;
   }
   /**
   * @return the mbps
   */
   public double getMbps() {
       return mbps;
   }
   /**
   * @param mbps
   * the mbps to set
   */
   public void setMbps(double mbps) {
       this.mbps = mbps;
   }
   /**
   * @return the gBUsed
   */
   public double getGBUsed() {
       return GBUsed;
   }
   /**
   * @param gBUsed
   * the gBUsed to set
   */
   public void setGBUsed(double gBUsed) {
       GBUsed = gBUsed;
   }
   public double totalCost() {
       double price = 0.0;
       price = mbps * 5 + GBUsed *
0.80;
       return price;
   }
   /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#toString()
   */
   @Override
   public String toString() {
       return super.toString()+"\nMbps = "
+ mbps + "\nGBUsed = " + GBUsed+"\nTotal Price
:$"+totalCost();
   }
}
===========================================


===========================================
// Test.java
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
       int
choice,mbps;
       double
noOfGBUsed,dPrice=0.0,mPrice=0.0;
       /*
       * Creating an Scanner class object
which is used to get the inputs
       * entered by the user
       */
       Scanner sc = new
Scanner(System.in);
       // Getting the input
entered by the user
       System.out.print("Enter the No of
MBPS :");
       mbps=sc.nextInt();
       System.out.print("Enter the No of
GB of data used :");
       noOfGBUsed=sc.nextInt();
      
       DPlan dp=new DPlan("DPlan", mbps,
noOfGBUsed);
       MPlan mp=new MPlan("MPlan", mbps,
noOfGBUsed);
       dPrice=dp.totalCost();
       mPrice=mp.totalCost();
      
System.out.println("\n-------------------------");
       System.out.println(dp);
      
System.out.println("-------------------------");
       System.out.println(mp);
      
System.out.println("-------------------------");
      
       if(dPrice<mPrice)
       {
          
System.out.println("\nThe Bst Plan is
:"+dp.getSubscriptionPlan());
       }
       else
       {
          
System.out.println("\nThe Bst Plan is
:"+mp.getSubscriptionPlan());
       }
      
      
   }
}
===========================================


===========================================
Output:

=====================Could you plz rate me well.Thank You