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

Hi there, can someone double check my code below please and correct any mistakes

ID: 3605839 • Letter: H

Question

Hi there, can someone double check my code below please and correct any mistakes? I'm having trouble understanding constructors so bear with me. Thank you all, any constructive critism is appreciated!

the TODO's are the questions and my answers are written below it

public class CCellPhoneType {
    // TODO Declare a private String member variable, named manufacturer

    private String manufacturer;


    // TODO Declare a private int member variable, named model

    private int model;


    // TODO Declare a private double member variable, named price

    private double price;


    // TODO Declare a public no-argument constructor (assigning the member variables with default values)

    public CCellPhoneType(){

    manufacturer = " ";
    model = 0;
    price = 0.0d;

    }
    
    
        // TODO Declare a public constructor with given inputs

        public CCellPhoneType(String varManufacturer, int varModel, double varPrice){
        manufacturer = varManufacturer;
        model = varModel;
        price = varPrice;
        }
    
    
        // TODO Return the value of the member variable manufacturer

        public String getManufacturer(){
        return manufacturer;
        }

        }
    

        // TODO Return the value of the member variable model    

        public int getModel(){
        return model;
        }

        }
    

        // TODO Return the value of the member variable price    

            public double getPrice(){
            return price;
            }

            }    
    
    
        // TODO Change the value of the member variable manufacturer by given input

        public static void manufacturer(String varManufacturer){
        varManufacturer = String manufacturer;

        return;

        }
    

        // TODO Change the value of the member variable model by given input

        public static void model(int varModel){
        varModel = int model;

        return;
        }
       
        }
    
    
        // TODO Change the value of the member variable price by given input

        public static void price(double varPrice){
        varPrice = double price;

        return;
        }    
    

        public String toString(){
             return "Cell phone settings: manufacturer - " + this.getManufacturer() + " model year - " + this.getModel() + " price - " + this.getPrice();
        }

        public static void main(String[] args) {
        // TODO decalre a CCellPhoneType instance, named myCellPhone


        CCellPhoneType myCellPhone=new CCellPhoneType();

        myCellPhone.setModel(2017);
        myCellPhone.setPrice(799.99);
        myCellPhone.setManufacturer("T-Mobile");
        System.out.println(myCellPhone.toString());
    
        // TODO decalre a CCellPhoneType instance with inputs, ("T-Mobile",2017,799.99) , named yourCellPhone

        CCellPhoneType yourCellPhone = new CCellPhoneType
        yourCellPhone.getPrice(799.99);
        yourCellPhone.getModel(2017);
        yourCellPhone.getManufacturer("T-Mobile");
        

        System.out.println(yourCellPhone.toString());
    }

}

Explanation / Answer

HI

I have fixed all issues and it is error free now

CCellPhoneType.java

public class CCellPhoneType {

// TODO Declare a private String member variable, named manufacturer

private String manufacturer;

// TODO Declare a private int member variable, named model

private int model;

// TODO Declare a private double member variable, named price

private double price;

// TODO Declare a public no-argument constructor (assigning the member variables with default values)

public CCellPhoneType(){

manufacturer = " ";

model = 0;

price = 0.0d;

}

  

  

// TODO Declare a public constructor with given inputs

public CCellPhoneType(String varManufacturer, int varModel, double varPrice){

manufacturer = varManufacturer;

model = varModel;

price = varPrice;

}

  

  

public String getManufacturer() {

return manufacturer;

}

public int getModel() {

return model;

}

public double getPrice() {

return price;

}

public void setManufacturer(String manufacturer) {

this.manufacturer = manufacturer;

}

public void setModel(int model) {

this.model = model;

}

public void setPrice(double price) {

this.price = price;

}

public String toString(){

return "Cell phone settings: manufacturer - " + this.getManufacturer() + " model year - " + this.getModel() + " price - " + this.getPrice();

}

public static void main(String[] args) {

// TODO decalre a CCellPhoneType instance, named myCellPhone

CCellPhoneType myCellPhone=new CCellPhoneType();

myCellPhone.setModel(2017);

myCellPhone.setPrice(799.99);

myCellPhone.setManufacturer("T-Mobile");

System.out.println(myCellPhone.toString());

  

// TODO decalre a CCellPhoneType instance with inputs, ("T-Mobile",2017,799.99) , named yourCellPhone

CCellPhoneType yourCellPhone = new CCellPhoneType("T-Mobile",2017,799.99);

yourCellPhone.getPrice();

yourCellPhone.getModel();

yourCellPhone.getManufacturer();

  

System.out.println(yourCellPhone.toString());

}

}

Output:

Cell phone settings: manufacturer - T-Mobile model year - 2017 price - 799.99
Cell phone settings: manufacturer - T-Mobile model year - 2017 price - 799.99

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote