Question: modify the CarCareChoice class so that as long as the user enters the first three characters of a service, the choice is considered valid. Rename

modify the CarCareChoice class so that as long as the user enters the first three characters of a service, the choice is considered valid. Rename the class CarCareChoice2.
heres what i have so far:
import java.util.Scanner;
public class CarCareChoice
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String [] services ={"oil change", "tire rotation", "battery check", "brake inspection"};
double [] price ={25,22,15,5};
for (String service : services)
{
System.out.println("-"+ service);
}
System.out.println("Please enter the name of the service you would like:");
String serviceChoice = input.nextLine().toLowerCase();
for (int i =0; i < services.length; i++){
if (serviceChoice.equals(services[i])){
System.out.println("Enter selection >>"+ services[i]);
System.out.println(services[i]+" price is "+ price[i]);
found = true;
break;
}
}
if (!found){
System.out.println("Wrong service selected");
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!