Question: A Phone class has 4 instance variables Model name (iPhone12,Galaxy) RAM (number of gigs such as 8 and12) Storage (number of gigs such as 128
A Phone class has 4 instance variables
- Model name ("iPhone12","Galaxy")
- RAM (number of gigs such as 8 and12)
- Storage (number of gigs such as 128 and 512)
- Screen of type class Screen as described below.
A Screen has 3 instance variables:
- Screen type ("AMOLED", "LCD")
- Screen size (decimal number such as 6.2 and 10.1)
- Screen ppi (448, 630, 300)
Q1) Code two class-shell for both classes.The names and types of the instance variables have deliberately been left up to you
Q2) Code a 6-parameter contractor for class Phone
- Do not rely on any auto-initialisation
- You can assume mutators exist for all instance variables
Q3) Code the toString method that should print all the specifications of the object that is invoked on.
Q4) Code a method called normalize() that accepts an array of integers 'intAr' and returns an array of doubles 'doubleAr'. The returned array must have the same length as the input. The method should convert any range of values in 'intAr' into 0..1 range.
For example:
if intAr=[-100,-50,0,50,100], doubleAr=[0.0,0.25,0.5,0.75,1.0]
How to normalize data?
where:
- doubleAr[i] is the ith element in the output array doubleAr
- intAr[i] is the ith element in the input array intAr
- min(intAr) is the minimum value in the input array intAr
- max(intAr) is the maximum value in the input array intAr
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
