Question: The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all

The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.

// Application lists valid shipping codes

// then prompts user for a code

// Application accepts a shipping code

// and determines if it is valid

import java.util.*;

public class DebugEight1

{

public static void main(String args[])

{

Scanner input = new Scanner(System.in);

char userCode;

String entry, message;

boolean found = false;

char[] okayCodes = ('A''C''T''H');

StringBuffer prompt = new

StringBuffer("Enter shipping code for this delivery Valid codes are: ");

for(int x = 0; x < length; ++x)

{

prompt.append(okayCodes[x]);

if(x != (okayCodes.length - 1))

prompt.append(", ");

}

System.out.println(prompt);

entry = input.next();

userCode = entry.charAt(0);

for(int i = 0; i < length; ++i)

{

if(userCode = okayCodes)

{

found = true;

}

}

if(found)

message = "Good code";

else

message = "Sorry code not found";

System.out.println(message);

}

}

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!