Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1: An electronics Shop wants to keep track of its inventory. It needs to save information about each cell phone it has. For each

Problem 1:

An electronics Shop wants to keep track of its inventory. It needs to save information about each cell phone it has. For each cell phone, it needs to know its brand, production year, memory size, number of cameras and price.

1. Create a Java class CellPhone that has the following attributes: (brand, production year, memory size, number of cameras and price). Give all attributes a suitable type and a private visibility.

2. Write two constructors for the class CellPhone: one without parameters, and another with parameters to fill all its attributes.

3. Write an accessor and a mutator method for each attribute. Make all methods public.

4. Write a toString() method to display the attributes of the class CellPhone

Testing:

5. Create a new Java Main class TestElectronics to test your CellPhone class. The class should have a main method to do the following:

a. Create an object of type CellPhone using the constructor without parameters

b. Set the brand of the cell phone to Android, production year to 2020, memory size to 200, number of cameras to 3, and price to 2500.00 using the mutator methods.

c. Display the cell phone object using the toString() method.

d. Create another object of type CellPhone using the constructor with parameters, setting the and give it appropriate values using the initialization constructor. e. Display the cell phone using the toString() method.

f. Open a file called electronics.txt that has all the information about the available cell phones in the store. The file will look like this:

Android 2020 400 3 3450.00

Apple 2019 360 3 2350.00

Huawei 2020 380 2 2280.50

Android 2019 350 2 2380.00

Then the main method should read the information about each cell phone from the input file, create an object of type CellPhone and initialize its attributes, then display this object using the toString() method.

g. Find and print the average price for all cellphones in the file.

h. Find and print the number of cell phones that has 3 or more cameras.

can some one solve it with java

thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions