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

Create a class that allows the user to ask what type of phone they want and what

ID: 3723850 • Letter: C

Question

Create a class that allows the user to ask what type of phone they want and what main feature. Return a yes if you have it and the price. Create a second class that has two arrays, one of type String that has the phone manufacturer, and two columns for feature one and feature two. A second array of type double that has the price. Create methods to allow the first class to determine if you have a phone of the type requested and if it has the feature desired. Also a method to return the price. (price explicitly)

Explanation / Answer

Hi.. Please check below.

PhnClass.java

import java.util.Arrays;

public class PhnClass {

   String manufacture[] = {"Samsung","Apple"};
   String features[][] = {{"Camera","Android"},{"Clarity","IOS"}};
  
   double price[] = {15000.00,35000.00};
  
   //both[0][0] = "ab";
  
   public double checkMobile(String type,String feature){
      
       for(int i=0;i<manufacture.length;i++){
          
           if(manufacture[i].equalsIgnoreCase(type)){
              
               if(features[i][0].equalsIgnoreCase(feature) || features[i][1].equalsIgnoreCase(feature)){
                   return price[i];
               }
              
           }
          
          
       }
      
       return 0;
   }
}

CheckDriver.java

import java.util.Scanner;

public class CheckDriver {

   public static void main(String[] args) {
       // TODO Auto-generated method stub

       Scanner sc = new Scanner(System.in);
       System.out.println("Enter type of phone:");
       String type = sc.nextLine();
      
       System.out.println("Enter feature of phone:");
       String feature = sc.nextLine();
      
       PhnClass p = new PhnClass();
       double rate = p.checkMobile(type, feature);
       if(rate==0){
           System.out.println("Sorry item not found with the above details!");
       }else{
           System.out.println("Rate of phone: $"+rate);
       }
      
   }

}

Output:

Enter type of phone:
Apple
Enter feature of phone:
IOS
Rate of phone: $35000.0

Please test the code and let me know any issues. Thank you. All the best.

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