Question: JAVA Code Below that I am trying and keep erroring out. I just need the below fixed not the entire code. I keep trying to

JAVA

Code Below that I am trying and keep erroring out. I just need the below fixed not the entire code. I keep trying to figure it out but am stuck.

drWord = word.substring(word + indexOf("dr"),4);

Assume that word is a variable of type String that has been assigned a value. Assume furthermore that this value always contains the letters dr followed by at least two other letters. For example: undramatic, dreck, android, no-drip.

Assume that there is another variable declared, drWord, also of type String. Write the statements needed so that the 4-character substring word of the value of word starting with dr is assigned to drWord. So, if the value of word were George slew the dragon your code would assign the value drag to drWord.

JAVA Code Below that I am trying and keep erroring out. I

There is a compilation error in your submission. Compiler Errors Harness.java:10: error: cannot find symbol drWord = word.substring(word + indexOf ("dr"),4); symbol: method indexOf(String) location: class Harness 1 error Our Code (in grey) Your Code (bolded, in white) 1 import java.util.*; import java.io.*; 2 3 4 class Harness { public static void main(String [] args) throws Exception { 5 6 7 String word = ""; String drWord = ""; 8

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 Databases Questions!