The files provided 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.
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\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";
else
message = "Sorry code not found";
System.out.println(message);
}
}
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\nValid codes are: ");
for (int x = 0; x < okayCodes.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 < okayCodes.length; ++i) {
if (userCode == okayCodes[i]) {
found = true;
}
}
if (found)
message = "Good code";
else
message = "Sorry code not found";
System.out.println(message);
}
}
The files provided contain syntax and/or logic errors. In each case, determine and fix the problem,...
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. // Prompt user for value to start // Value must be between 1 and 20 inclusive // At command line, count down to blastoff // With a brief pause between each displayed value import java.util.*; public class DebugSix3 { public static void...
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. // DebugFive2.java // Decides if two numbers are evenly divisible import java.util.Scanner; public class DebugFive2 { public static void main(String args[]) { int num; int num2; Scanner input = new Scanner(System.in); System.out.print("Enter a number "); num = input.nextInteger() System.out.print("Enter another number ");...
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. public class DebugTwo1 { public static void main(String[] args) { integer oneInt = 315; double oneDouble = 12.4; character oneChar = 'A'; System.out.print("The int is "); System.out.println(oneint); System.out.print("The double is "); System.out.println(onDouble); System.out.print("The char is "); System.out.println(oneChar); } }
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. // Start with a penny // double it every day // how much do you have in a 30-day month? public class DebugSix1 { public static void main(String args[]) { final int DAYS = 30; double money = 0.01; int day =...
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. Note: DebugDataOne1.txt and DebugDataOne2.txt do not need to be edited. They are used by the program. import java.nio.file.*; import java.nio.file.attribute.*; import java.io.IOException; public class DebugThirteen1 { public static void main(String[] args) { Path file1 = Paths.get("/root/sandbox/DebugDataOne1.txt"); // path to file DebugDataOne1.txt in...
For the below code find and fix the errors then tell what the output would be. import java.utils.*; public class pin public void main(String[] args); { char s; int num; Scanner br = Scanner(System.in); System.out.print("Enter the first letter of your name :"); s = BR.next().charAt(0); num = s; System.out.println(“The value associated with your letter is” num); }
Change the following Shift Cipher program so that it uses OOP(constructor, ect.) import java.util.*; import java.lang.*; /** * * @author STEP */ public class ShiftCipher { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner(System.in); String plainText; System.out.print("Please enter your string: "); // get message plainText = input.nextLine(); System.out.print("Please enter your shift cipher key: "); // get s int s = input.nextInt(); int...
Hello, can someone please fix my code? It runs perfect but I'm having trouble with the index for the incorrect answer array; please run some tests to ensure the code runs properly, thank you! Here is the code: ___________________________________________________________________________________________________________________________ import java.util.Scanner; public class DriverTest{ final static int QuestionTotal = 10; public static void main(String[] args){ // scanner and answer key Scanner scan = new Scanner(System.in); final char[] answers = {'A', 'B', 'C',...
Correct the five syntax, run-time or logic errors that are found in the CountAndAverageNumbers.java file. Link to the file: CountAndAverageNumbers.javaPreview the document. Make sure you include comments in your code where errors were corrected. If you do not flag each error with a comment, points will be deducted. Upload the corrected .java file here. The output of the corrected file looks like the following: Debug4Output.PNG This program reads an unspecified number of integers, determines how many positive and negative values...
JAVA: Rewrite the following code to where the inputs are from a file. The file name will be from the input from the user scanner. CODE: import java.util.*; public class Q1 { public static int sumOD (int k) { int sumOD = 0; int in = k; while (in != 0) { int digitON = in % 10; sumOD += digitON; in /= 10; } return sumOD; } public static void main(String[] args) { int n, i, k; System.out.println("Enter...