Question: java Exercise #2: A company keeps track of the computers it buys for its employees. Create a class Computer, which has the following member variables:
Exercise \#2: A company keeps track of the computers it buys for its employees. Create a class Computer, which has the following member variables: - personName (String), (Name of the person in the company using the computer). - cost (double), (The cost of the computer when it was bought). - cpuSpeed (float). - age (int), (Number of days since the computer has been bought). - memorySize (int), (RAM size in megabytes). Add a default constructor (set the values to empty string and zeros), and an intialization constructor. The class has the following member functions: - Accessors and mutators. - A method toString() should return the data member values at once. - A method sell() which returns the price for a computer if we want to sell it, knowing that if a computer was bought more than 2 years ago, a discount of 50% on the riginal cost is made, otherwise the discount is 25%. - A method ageInYears () which returns the age of a computer object in years. - A method print () which prints the details of a computer in a neat format including its current price (if we want to sell it) and its age in days. Write a test program where you do the following: - Instantiate three different objects of type Computer with the following details (name, cost, CPU speed, age in days, memory size): - computer1 attributes: Yousef, 5500.50,2.7,100,1024 - computer2 attributes: no details given. - computer3 attributes: Aysha, 1000.25,1.8,850,512 - Print the details of each computer. - Set the data of the second computer to some new data to be read from the keyboard. - Write the details of the second computer after its details have been read. - Print the details of each computer
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
