Can anyone solve question 4 5 6 in Java? I\'ve solved first 3 questions and here
ID: 3784948 • Letter: C
Question
Can anyone solve question 4 5 6 in Java?
I've solved first 3 questions and here are the answers below.
Thanks a lot.
D Microsoft Word CCM C Chegg study I Guided x C file://IC/Users/victor0323/Downloads/COMP1406 A2 W2017%2001).pdf Assume that a cell phone retailer wanted you to write a program to keep track of its inventory. Define an object called CellPhone which maintains state representing a cell phone's model (a string), manufacturer (a string), monthsWarranty (an integer) and price (a float). All instance variables (i.e. attributes) should be made private. Create a zero-parameter constructor as well as one that takes all 4 parameters (in the order listed above). Also create get and set methods for each attribute. Save and compile the file. The program below is called CellPhoneTestProgram and it should test your CellPhone methods. However, the testing code is incomplete (see highlighted areas). Please complete the testing code according to the directions given, then test out the code to make sure that it works: public class Cell PhoneTestProgram public static void main (String ar Create thr Cell Phone objects One should be iPhone 6P7u e from Apple which has 12 month wa ranty and coats $915 Another ell should be Galaxy 57 from Samsung with an 18 month wa ranty, and a price of $900.00 The last phone should be a from BlackBerry wi a 24 non ch PRIV war. price of 3890.00 WRITE IN MISSING coog Cellphone iPhone Cell Phone galaxy WRITE IN MISSING CODE Cell Phone priv WRITE System.out.println Here is the Apple phone information System.out.println(iPhone. getModel System.out.println (iPhone.getManufacturer System.out.println iPhone getMonths Warranty System out, Phone get Price System.out. ntln "AnHere is the Samsung phone information System out prin ga get Model System.out.println (galaxy.getManufacturer System. out.println (galaxy getMontha Warranty 0); System. out.println (galaxy.getPrice System.out.println InHere is the BlackBerry phone information System out.println getModel i System out.println priv,get Manufacturer System. out.println (priv. getMonths Warranty Syst tl get P a 0:36 NG 2017/1/28Explanation / Answer
Hi,
PFB the Customer.java. Please comment for any feedbacks/queries.
Thanks,
Anita
public class Customer {
private String name;
private CellPhone cellphoneType;
private PhonePlan phoneplanType;
private int noOfCallsMade;
private float balance;
//Parametrrzed constructor
public Customer(String name, CellPhone cellphoneType, PhonePlan phoneplanType ){
this.name= name;
this.cellphoneType = cellphoneType;
this.phoneplanType =phoneplanType;
if(phoneplanType.planType ){
this.balance =(float) 0.40;
}
else{
this.balance =0;
}
this.noOfCallsMade =0;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public CellPhone getCellphoneType() {
return cellphoneType;
}
public void setCellphoneType(CellPhone cellphoneType) {
this.cellphoneType = cellphoneType;
}
public PhonePlan getPhoneplanType() {
return phoneplanType;
}
public void setPhoneplanType(PhonePlan phoneplanType) {
this.phoneplanType = phoneplanType;
}
public int getNoOfCallsMade() {
return noOfCallsMade;
}
public void setNoOfCallsMade(int noOfCallsMade) {
this.noOfCallsMade = noOfCallsMade;
}
public float getBalance() {
return balance;
}
public void setBalance(float balance) {
this.balance = balance;
}
public String toString(){
String strVal=this.name+ " with a "+this.cellphoneType+"on a " +this.phoneplanType.toString();
//System.out.println(strVal);
return strVal;
}
public void phone(Customer customer, int callLength){
if(this.phoneplanType.planType){
if(callLength>this.phoneplanType.getMinutesRemaining()){
//nothing happens
}
else{
this.phoneplanType.minutesUsed= this.phoneplanType.minutesUsed+callLength;
this.setNoOfCallsMade(this.getNoOfCallsMade() +1);
customer.phoneplanType.minutesUsed = customer.phoneplanType.minutesUsed +callLength;
customer.setNoOfCallsMade(customer.getNoOfCallsMade() +1);
}
}
}
public void buyMinutes(int minutes){
if(this.phoneplanType.planType){
this.setBalance(this.getBalance()+ (new Float(0.40) * minutes));
this.phoneplanType.minutesAllowed = this.phoneplanType.minutesAllowed +minutes;
}
else{
//For regular,, do nothing
}
}
public void accessInternet(int dataUsed){
this.phoneplanType.setDataUsed(this.phoneplanType.dataUsed +dataUsed);
}
public void printMonthlyStatement(){
String planStr="";
int monthlyCharge=0;
String monthlyChargeStr;
double voiceOverTimeCharge=0;
double dataOverUsageCharge=0;
double HST=0;
double totalDue=0;
if(this.phoneplanType.planType==true){
planStr = String.format("Pay-as-you-go Plan "+this.phoneplanType.minutesAllowed+" minutes and "+this.phoneplanType.dataAllowed+"KB data");
} else{
planStr = String.format("Regular Monthly ("+this.phoneplanType.minutesAllowed+" minutes, "
+(((double)this.phoneplanType.dataAllowed)/(1000*1000)))+"GB data)";
}
if(200 == this.phoneplanType.minutesAllowed){
monthlyCharge =25;
}
else if(100 == this.phoneplanType.minutesAllowed){
monthlyCharge =15;
}
if(this.phoneplanType.dataAllowed>0){
int dataCharge= (int) (10*this.phoneplanType.dataAllowed);
monthlyCharge = monthlyCharge +dataCharge;
}
monthlyChargeStr =String.valueOf(monthlyCharge);
//get voiceOverTimeCharge charge
if(this.phoneplanType.getMinutesRemaining()<0){
int voiceOverTimeMinute;
voiceOverTimeMinute =(int) -(this.phoneplanType.getMinutesRemaining());
voiceOverTimeCharge = voiceOverTimeMinute * .15;
}
//get dataOverUsageCharge charge
if(this.phoneplanType.getDataRemaining()<0){
int dataOver;
dataOver =(int) -(this.phoneplanType.getDataRemaining());
dataOverUsageCharge = dataOver * .00005;
}
//get HST
HST = (voiceOverTimeCharge + dataOverUsageCharge +monthlyCharge ) *.13;
//get totalDue
totalDue = voiceOverTimeCharge + dataOverUsageCharge +monthlyCharge +HST;
System.out.println("Name: "+this.name);
if(this.phoneplanType.planType){
System.out.println("Plan Type: "+"Pay-as-you-go");
}
else{
System.out.println("Plan Type: "+planStr);
}
System.out.println("Minutes Used: "+this.phoneplanType.minutesUsed);
if(this.phoneplanType.planType){
System.out.println("Minutes Remaining: "+this.phoneplanType.getMinutesRemaining());
}
System.out.println("Data Used: "+this.phoneplanType.dataUsed);
if(this.phoneplanType.planType){
System.out.println("Data Remaining: "+this.phoneplanType.getDataRemaining());
}
System.out.println("Calls Made: "+this.getNoOfCallsMade());
System.out.println("Monthly Charges: "+monthlyChargeStr);
if(!this.phoneplanType.planType){
System.out.println("Voice Overtime Charges: "+voiceOverTimeCharge);
System.out.println("Data Overusage Charges: "+dataOverUsageCharge);
}
System.out.println("HST: "+HST);
System.out.println("Total Due: "+totalDue);
}
}
Sample Output:
part 4:
Sample output:
Rob Banks with a CellPhone@f991bd1eon a Regular (200 minute, 2.5GB data) Monthly Plan with 200 minutes remaining and 2500000KB remaining
Rita Book with a CellPhone@ddb3a290on a Regular (100 minute, 0.5GB data) Monthly Plan with 100 minutes remaining and 500000KB remaining
Sue Permann with a CellPhone@f991bd1eon a Regular (60 minute, 2.5GB data) Monthly Plan with 60 minutes remaining and 2500000KB remaining
Tim Bur with a CellPhone@f991bd1eon a Pay-as-you-go Plan with 30 minutes and 0KB remaining
April Rain with a CellPhone@4cdc0b7don a Pay-as-you-go Plan with 200 minutes and 1000000KB remaining