Question: This is what im told to do: It might not be reasonable to expect users to type long entries such as oil change accurately. Copy
This is what im told to do:
It might not be reasonable to expect users to type long entries such as "oil change" accurately. Copy the code from the CarCareChoice.java file into the CarCareChoicejava file and modify the CarCareChoice class so that as long as the user enters the first three characters of a service correctly, the choice is considered valid. Rename the class CarCareChoice
This is what i have. The code works but only when i enter the first letter. I want to be able to enter the whole word and if the first letter are correct the code should work. I want to be able to enter more than just the first letters of the word
This is the error i get:
Status: FAILED! Test: The CarCareChoice program accepts misspelled selections. Reason: In this simulation, the input value was 'brack check'. The cost of a brake inspection is $ Unable to find in the program's output. Error : class java.lang.AssertionError
Here is my code:
import java.util.;
public class CarCareChoice
public static void mainString args
Scanner input new ScannerSystemin;
String services oil change", "tire rotation", "battery check", "brake inspection";
double price ;
for String service : services
System.out.println service;
System.out.printlnPlease enter the name of the service you would like:";
String serviceChoice input.nextLinetoLowerCase;
boolean found false;
for int i ; i services.length; i
if servicesitoLowerCasestartsWithserviceChoice
System.out.printlnYou selected: servicesi;
System.out.printlnservicesi price is $ pricei;
found true;
break;
if found
System.out.printlnInvalid service selection. Please try again.";
input.close;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
