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

i need help with this java program, please answer as soon as possible: modify re

ID: 659176 • Letter: I

Question

i need help with this java program, please answer as soon as possible:

modify rental class to:
-contain an Equipment data field and an additional price field
that hold a base price before equipment fees are added.
-remove the array of equipment Strings from the Rental class as well
as the method that returns an equipment String.
-modify the Rental constructor so that it requires three parameters: contract number,minutes for the rental, and an equipment type.
-the method that sets the hours and minutes now sets a base price before
equipment fees are included
-within the constructor, set the contract numer and time as before, but add statments to create a EquipmentWithLesson object and assign it to the Equipment data field.
-assign the sum of the base price(based on time) and the equipment fee(based on the type of equipment) to the price field.
-save as RentalEquipment.java

_____________rental class in shown below____________

public class Rental
{
public static final int MINUTES_IN_HOUR = 60;
public static final int HOUR_RATE = 40;
public static final int CONTRACT_NUM_LENGTH = 4;
public static final String[] EQUIP_TYPES =
{"jet ski", "pontoon boat", "rowboat", "canoe", "kayak",
"beach chair", "umbrella", "other"};
private String contractNumber;
private int hours;
private int extraMinutes;
private double price;
private String contactPhone;
private int equipType;
public Rental(String num, int minutes)
{
setContractNumber(num);
setHoursAndMinutes(minutes);
}
public Rental()
{
this("A000", 0);
}
public void setContractNumber(String num)
{
boolean numOk = true;
if(num.length() != CONTRACT_NUM_LENGTH ||
!Character.isLetter(num.charAt(0)) ||
!Character.isDigit(num.charAt(1)) ||
!Character.isDigit(num.charAt(2)) ||
!Character.isDigit(num.charAt(3)))
contractNumber = "A000";
else
contractNumber = num.toUpperCase();
}
public void setHoursAndMinutes(int minutes)
{
hours = minutes / MINUTES_IN_HOUR;
extraMinutes = minutes % MINUTES_IN_HOUR;
if(extraMinutes <= HOUR_RATE)
price = hours * HOUR_RATE + extraMinutes;
else
price = hours * HOUR_RATE + HOUR_RATE;
}
public String getContractNumber()
{
return contractNumber;
}
public int getHours()
{
return hours;
}
public int getExtraMinutes()
{
return extraMinutes;
}
public double getPrice()
{
return price;
}
public String getContactPhone()
{
String phone;
phone = "(" + contactPhone.substring(0, 3) + ") " +
contactPhone.substring(3, 6) + "-" +
contactPhone.substring(6, 10);
return phone;
}
public void setContactPhone(String phone)
{
final int VALID_LEN = 10;
final String INVALID_PHONE = "0000000000";
contactPhone = "";
int len = phone.length();
for(int x = 0; x < len; ++x)
{
if(Character.isDigit(phone.charAt(x)))
contactPhone += phone.charAt(x);
}
if(contactPhone.length() != VALID_LEN)
contactPhone = INVALID_PHONE;
}
public void setEquipType(int eType)
{
if(eType < EQUIP_TYPES.length)
equipType = eType;
else
equipType = EQUIP_TYPES.length - 1;
}
public int getEquipType()
{
return equipType;
}
public String getEquipTypeString()
{
return EQUIP_TYPES[equipType];
}   
}

_________________Equipment class is show below__________

import java.util.*;
abstract class Equipment
{
int equipmenttype;
double equipmentfee;
final String equipmentname[]={"jet ski","pantoon boat","row boat","canoe","beach chair","umbrella","other"};
final int subcharge[]={50,40,15,12,10,2,1,0};
Equipment() //Default constructor of abstract class
{
equipmenttype=0;
Scanner s=new Scanner(System.in); //Scanner object s
do //Repeat if invalid equiptment type
{
System.out.println("Enter Equiptment type(1-8 only)");
equipmenttype=s.nextInt();
if(equipmenttype>8 || equipmenttype<1)
System.out.println("Invalid item type(1-8 only)try again"); //error printing and repeat
}
while(!(equipmenttype>=1) && !(equipmenttype<=8));
}
  
//Set methods
void setEquipmentFee(double fee)
{equipmentfee=fee;}

//Get methods
String getEquipmentName()
{ return equipmentname[equipmenttype];}
  
double getEquipmentFee()
{ return equipmentfee;}
  
int getType()
{return equipmenttype;}
  
double getSubcharge()
{return subcharge[equipmenttype];}

//Printing all respective toString()   
public String toString()
{
return equipmenttype+","+equipmentname[equipmenttype-1]+","+subcharge[equipmenttype-1];
}
}

____________EquipmentWithLesson shown below___________

class EquipmentWithLesson extends Equipment //Extends abstract class
{
EquipmentWithLesson(double fee) //Constructor with parameter
{
super(); //Abstract class constructor
equipmentfee=fee;
}
  
public String toString() //Calling super class toString+current field
{
return super.toString()+","+equipmentfee;
}
}

Explanation / Answer

_____________rental class in shown below____________

public class Rental
{
public static final int MINUTES_IN_HOUR = 60;
public static final int HOUR_RATE = 40;
public static final int CONTRACT_NUM_LENGTH = 4;
private String contractNumber;
private int hours;
private int extraMinutes;
private double price;
private String contactPhone;
private int equipType;
public Rental(String num, int minutes,int equipType;)
{
setContractNumber(num);
setHoursAndMinutes(minutes);

setEquipType(int eType)


}
public Rental()
{
this("A000", 0);
}
public void setContractNumber(String num)
{
boolean numOk = true;
if(num.length() != CONTRACT_NUM_LENGTH ||
!Character.isLetter(num.charAt(0)) ||
!Character.isDigit(num.charAt(1)) ||
!Character.isDigit(num.charAt(2)) ||
!Character.isDigit(num.charAt(3)))
contractNumber = "A000";
else
contractNumber = num.toUpperCase();
}
public void setHoursAndMinutes(int minutes)
{
hours = minutes / MINUTES_IN_HOUR;
extraMinutes = minutes % MINUTES_IN_HOUR;
if(extraMinutes <= HOUR_RATE)
price = hours * HOUR_RATE + extraMinutes;
else
price = hours * HOUR_RATE + HOUR_RATE;
}
public String getContractNumber()
{
return contractNumber;
}
public int getHours()
{
return hours;
}
public int getExtraMinutes()
{
return extraMinutes;
}
public double getPrice()
{
return price;
}
public String getContactPhone()
{
String phone;
phone = "(" + contactPhone.substring(0, 3) + ") " +
contactPhone.substring(3, 6) + "-" +
contactPhone.substring(6, 10);
return phone;
}
public void setContactPhone(String phone)
{
final int VALID_LEN = 10;
final String INVALID_PHONE = "0000000000";
contactPhone = "";
int len = phone.length();
for(int x = 0; x < len; ++x)
{
if(Character.isDigit(phone.charAt(x)))
contactPhone += phone.charAt(x);
}
if(contactPhone.length() != VALID_LEN)
contactPhone = INVALID_PHONE;
}
public void setEquipType(int eType)
{
if(eType < EQUIP_TYPES.length)
equipType = eType;
else
equipType = EQUIP_TYPES.length - 1;
}
public int getEquipType()
{
return equipType;
}
   
}

_________________Equipment class is show below__________

import java.util.*;
abstract class Equipment
{
int equipmenttype;
double equipmentfee;
final String equipmentname[]={"jet ski","pantoon boat","row boat","canoe","beach chair","umbrella","other"};
final int subcharge[]={50,40,15,12,10,2,1,0};
Equipment() //Default constructor of abstract class
{
equipmenttype=0;
Scanner s=new Scanner(System.in); //Scanner object s
do //Repeat if invalid equiptment type
{
System.out.println("Enter Equiptment type(1-8 only)");
equipmenttype=s.nextInt();
if(equipmenttype>8 || equipmenttype<1)
System.out.println("Invalid item type(1-8 only)try again"); //error printing and repeat
}
while(!(equipmenttype>=1) && !(equipmenttype<=8));
}
  
//Set methods
void setEquipmentFee(double fee)
{equipmentfee=fee;}

//Get methods
String getEquipmentName()
{ return equipmentname[equipmenttype];}
  
double getEquipmentFee()
{ return equipmentfee;}
  
int getType()
{return equipmenttype;}
  
double getSubcharge()
{return subcharge[equipmenttype];}

//Printing all respective toString()   
public String toString()
{
return equipmenttype+","+equipmentname[equipmenttype-1]+","+subcharge[equipmenttype-1];
}
}

____________EquipmentWithLesson shown below___________

class EquipmentWithLesson extends Equipment //Extends abstract class
{
EquipmentWithLesson(double fee) //Constructor with parameter
{
super(); //Abstract class constructor
equipmentfee=fee;
}
  
public String toString() //Calling super class toString+current field
{
return super.toString()+","+equipmentfee;
}
}