Question

Programming 4_1: Create a class call CellPhone. This class represents a cell phone. The data a...

Programming 4_1: Create a class call CellPhone. This class represents a cell phone. The data a cellphone should contains: manufact- the name of the phone’s manufacturer; model – the phone’s model number; retailPrice – the phone’s retail price. The class will have the following methods: 1)A constructor that accepts arguments for manufacturer, model number, and retail price. 2)A setManufact method that accepts an argument for the manufacturer. This method will allow us to change the value of manufact field after the object has been created, if necessary. 3)A setModel method that accepts an argument for the model number. This method will allow us to change the value of model field after the object has been created, if necessary. 3)A setRetailPrice method that accepts an argument for the retail price. This method will allow us to change the value of retailPrice field after the object has been created, if necessary. 4)A getManufact method that returns the phon’s manufacturer. 5) A getModel method that returns the phone’s model number. 6)A getRetailPrice methos that returns the phone’s retail price. Create a second tester class call CellPhoneTester with a main method.  Create an Apple iphone with model number F2LQQ6KVGRX3, retail price $599.  Change the retail price to $399.  Get the current retail price by calling the method of the iphone. You can test your method by creating a few other cellphones, and calling more methods from main method.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;

class CellPhone
{
String manfName;
String modelNo;
double price;

CellPhone(String nm,String no,double p)
{
setManufact(nm);
setModel(no);
setRetailPrice(p);
}

void setManufact(String nm)
{
manfName=nm;
}

void setModel(String no)
{
modelNo=no;
}

void setRetailPrice(double p)
{
price=p;
}

String getManufact()
{
return manfName;
}

String getModel()
{
return modelNo;
}

double getRetailPrice()
{
return price;
}

}

class CellPhoneTester
{
public static void main(String args[])
{
CellPhone cp=new CellPhone("Apple_iPhone","F2LQQ6KVGRX3",599);
System.out.println("\n\nThe name of the phone's manufacturer : "+cp.getManufact());
System.out.println("\nThe phone's model number : "+cp.getModel());
System.out.println("\nThe phone's retail price : $"+cp.getRetailPrice());
cp.setRetailPrice(399);
System.out.println("\nThe current retail price : $"+cp.getRetailPrice());
System.out.println("\n");
}
}

Add a comment
Know the answer?
Add Answer to:
Programming 4_1: Create a class call CellPhone. This class represents a cell phone. The data a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a class named Month. The class should have an int field named monthNumber that holds...

    Write a class named Month. The class should have an int field named monthNumber that holds the number of the month. For example. January would be 1. February would be 2. and so forth. In addition, provide the following methods A no-arg constructor that sets the monthNumber field to 1 A constructor that accepts the number of the month as an argument. It should set the monthNumber field to the value passed as the argument. If a value less than...

  • C++ programming Phone Book Create a class that can be used for a Phone Book. The...

    C++ programming Phone Book Create a class that can be used for a Phone Book. The class should have attributes for the name and phone number. The constructor should accept a name and a phone number. You should have methods that allow the name to be retrieved, the phone number to be retrieved, and one to allow the phone number to be changed. Create a toString() method to allow the name and number to be printed. Write a program that...

  • Application should be in C# programming language Create a class called SavingsAccount.  ...

    Application should be in C# programming language Create a class called SavingsAccount.  Use a static variable called annualInterestRate to store the annual interest rate for all account holders.  Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance.  Provide static method setAnnualInterestRate to set the...

  • Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing...

    Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing this assignment, students will practice Object Oriented design and programming by creating a Java program that will implement Object Oriented basic concepts. RetailItem Class: Part 1: Write a class named RetailItem that holds data about an item in a retail store. The class should have the following fields: • description. The description field references a String object that holds a brief description of the...

  • Looking for some help here: Edit GetPhoneData to add more input validation by setting ranges for...

    Looking for some help here: Edit GetPhoneData to add more input validation by setting ranges for values Brands (Samsung, iPhone, Google) Models (Galaxy, Note, 8, X, Pixel) Price ($0.01-$2000) Include a comment about your addition, you can be creative, add components (or not), individualize this. Extra Credit (Samsung must be paired to Galaxy or Note) 2 points Below is the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Cell_Phone_Test {...

  • in python Write a class named RetaiI_Item that holds data about an item in a retail...

    in python Write a class named RetaiI_Item that holds data about an item in a retail store. The class should store the following data in attributes: • Item Number • Item Description • Units in Inventory • Price Create another class named Cash_Register that can be used with the Retail_Item class. The Cash_Register class should be able to internally keep a list of Retail_Item objects. The class should include the following methods: • A method named purchase_item that accepts a...

  • Create the header file named “Complex.h” that contains the following class: The class Complex represents a...

    Create the header file named “Complex.h” that contains the following class: The class Complex represents a complex number which is a number of the form a + bi where a and b are real numbers and i2 = −1. The class should contain: Private double field named real. Private double field named imaginary. Public default constructor that assigns 1 to real and 0 to imaginary. Public overloaded constructor that takes a double as a parameter named real. It assigns real...

  • Create a Mattress class should have fields for size (king, queen, twin), manufacturer, and price, and...

    Create a Mattress class should have fields for size (king, queen, twin), manufacturer, and price, and a constructor should set default values for each. Write set methods only for size and manufacturer. The set method for size adds $200 for king or $100 for queen. Add a toString() method that returns the data from all of the fields. A child class named AdjustableMattress extends Mattress and adds a field for adjustment type (air or mechanical), with air being the default....

  • M01 PA C++ Classes and Objects INTRODUCTION: Write a C++ program that implements and utilizes a...

    M01 PA C++ Classes and Objects INTRODUCTION: Write a C++ program that implements and utilizes a Stereo Receiver Class/Object. INCLUDE IN YOUR ASSIGNMENT At the top of each of your C++ programs, you should have at least four lines of documentation: Program name (the C++ file name(s)), Author (your name), Date last updated, and Purpose (a brief description of what the program accomplishes). Here is an example: // Program name: tictactoe.cpp // Author: Rainbow Dash // Date last updated: 5/26/2016...

  • Write a Gui programming by using JavaFx menus, stage and screen concepts to the RetailItem class,...

    Write a Gui programming by using JavaFx menus, stage and screen concepts to the RetailItem class, Write a class named Retailltem that holds data about an item in a retail store. The class should have the following fields description: The description field is a String object that holds a brief description of the item . unitsOnHand: The unitsOnHand field is an int variable that holds the number of units currently in inventory Price: The price field is a double that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT