1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Harrizon [31]
4 years ago
8

Can I have some help debugging this exercise:// Application lists valid shipping codes// then prompts user for a code// Applicat

ion accepts a shipping code// and determines if it is validimport 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 = newStringBuffer("Enter shipping code for this delivery\nValid 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";elsemessage = "Sorry code not found";System.out.println(message);}}
Computers and Technology
1 answer:
gizmo_the_mogwai [7]4 years ago
3 0

Answer:

See Explanation

Explanation:

The following lines of codes were corrected.

<em>Note only lines with error are listed out</em>

char[] okayCodes = {'A''C''T''H'};

corrected to

char[] okayCodes = {'A','C','T','H'};

StringBuffer prompt = newStringBuffer("Enter shipping code for this delivery\nValid codes are: ");

corrected to

StringBuffer prompt = new StringBuffer("Enter shipping code for this deliveryValid codes are: ");

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

corrected to

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

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

corrected to

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

if(userCode = okayCodes)

corrected to

if(userCode == okayCodes[i])

if(found)message = "Good code";elsemessage = "Sorry code not found";

corrected to

if(found)

message = "Good code";

else

message = "Sorry code not found";

<em>However, I've added the full source code as an attachment</em>

Download java
You might be interested in
[30 points, will mark Brainliest] Which of the following is the lowest hexadecimal value? Explain why. Options to chose; F2, 81,
larisa86 [58]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

First, we need to convert these hexadecimal numbers into decimal numbers, then we can easily identify which one is the lowest hexadecimal.

The hexadecimal numbers are F2, 81, 3C, and 39.

F2 = (F2)₁₆ = (15 × 16¹) + (2 × 16⁰) = (242)₁₀

81 = (81)₁₆ = (8 × 16¹) + (1 × 16⁰) = (129)₁₀

3C = (3C)₁₆ = (3 × 16¹) + (12 × 16⁰) = (60)₁₀

39 = (39)₁₆ = (3 × 16¹) + (9 × 16⁰) = (57)₁₀

The 39 is the lowest hexadecimal number among the given numbers.

Because 39 hex is equal to 57 decimal.

39 = (39)₁₆ = (3 × 16¹) + (9 × 16⁰) = (57)₁₀

5 0
3 years ago
Do all light bulbs server a practical purpose?
Greeley [361]

Answer:

A light bulb produces light from electricity

6 0
4 years ago
To save a document with a new name, click _______ in the navigation bar and enter a new filename.
cricket20 [7]
Click the save as button
3 0
4 years ago
+
quester [9]

Answer:

Network administrator

5 0
3 years ago
Read 2 more answers
Limiting the amount of personal information available to others includes reducing your ______________ footprint
Gala2k [10]

The blank should be filled with "digital"

6 0
4 years ago
Other questions:
  • Create a text file that contains your expenses for last month in the following categories: • Rent • Gas • Food • Clothing • Car
    13·1 answer
  • Which of the following statements regarding EFT is false? EFT still requires the endorsement of a check EFT allows payment to be
    11·1 answer
  • An intranet is an external network.TrueFalse
    15·1 answer
  • Read the following scenario: A project will require more people than originally estimated. Identify the possible risks to the pr
    8·2 answers
  • Under which of the following conditions will evaluating this boolean expression
    7·1 answer
  • Placeholders can hold text but not graphics such as photos or charts. True or false?
    7·1 answer
  • What are the origins of the parking barrier?
    12·1 answer
  • What is gained by increasing the ritation speed of a disk or cd?​
    9·1 answer
  • If you answer I will mark brainliest!!! I want to be able to see two websites on my screen at the same time, how do I do that on
    9·1 answer
  • It specifies the amount of memory needed to store data.
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!