a. DebugOne1.java
Explanation of Solution
Errors in the given program:
In the given program “DebugOne1.java”, there are two errors, they are,
- The block comment section is not closed in Line 3.
- The keyword “static” is missing in Line 4.
- The highlighted lines are the corrected statements in the given program.
Corrected Program:
// Class definition
public class FixDebugOne1 // Line 1
{ // Line 2
/* This program displays a greeting */ // Line 3
public static void main(String[] args) // Line 4
&...
b. DebugOne2.java
Explanation of Solution
Errors in the given program:
In the given program “DebugOne2.java”, there are two errors, they are,
- The print statements are given wrongly; the correct statement to print is “System.out.println”.
- The double quotes in print statement are missing in Line 8 and Line 10.
Corrected Program:
// Class definition
public class FixDebugOne2 // Line 1
{ // Line 2
/* This program displays some output*/ // Line 3
public static void main(String[] args) // Line 4
{ // Line 5
// Display the statement
System.out...
c. DebugOne3.java
Explanation of Solution
Errors in the given program:
In the given program “DebugOne3.java”, there are two errors, they are,
- The main method is not defined properly, the square brackets “[]” is missing in String function.
- The print statements are given wrongly;
- In Line 6, the letter “l” should be typed instead of “1”.
- In Line 7, the letter “i” should be typed instead of “1”.
- In Line 8, the letter “S” should be in uppercase instead of lowercase “s”.
Corrected Program:
// Class definition
public class FixDebugOne3 // Line 1
{ // Line 2
/* This program displays some output*/ // Line 3
public static void main(String[] args) // Line 4
{ ...
d. DebugOne4.java
Explanation of Solution
Errors in the given program:
In the given program “DebugOne4.java”, there are few errors, they are,
- In the main method in Line 3, the “static” keyword is misspelled.
- In Line 4, the “JOptionpane” class is misspelled, it should be “JOptionPane”.
- In Line 4, the parameter “nul” in “JOptionPane” class is misspelled, it should be “null”.
Corrected Program:
// Import the package
import javax.swing...
Trending nowThis is a popular solution!
Chapter 1 Solutions
EBK JAVA PROGRAMMING
- java programmingarrow_forwardWrite an application named, Lab14.java. This application will do the following: 1. Display an introductory message 2. Choose a random word from the file, wordlist.txt, and display it 3. Disguise the selected word, and display it 4. Ask the user whether to continue, i.e., whether to repeat steps 2, 3, and 4, or quit the application Once the user chooses to stop the application: 5. Display the total number of vowels hidden 6. Display the total number of consonants hidden 7. Display termination message The user will be asked whether to continue playing and will indicate that another game is to be played by answering ‘y’ or ‘Y’ in response to the question, “Want to play again?” asked by the program after displaying each chosen word and its disguised version. If the user’s response is any character other than ‘y’ or ‘Y’, the totals are displayed and then the application termination message is displayed. See examples below. About randomly choosing a word from the file, wordlist.txt, found on…arrow_forwardThe file Names.txt is located in the folder input_files within your project. The content of that file is shown in the following figure Java: import java.io.FileInputStream;import java.io.FileNotFoundException;import java.util.ArrayList;import java.util.Scanner;public class Question2 {public static void main(String[] args) throws FileNotFoundException {/*** Part a* Finish creating an ArrayList called NameList that stores the names in the file Names.txt.*/ArrayList<String> NameList;/*** Part b* Replace null on the right-hand-side of the declaration of the FileInputStream object named inputStream* so that it is initialized correctly to the Names.txt file located in the folder specified in the question description*/FileInputStream inputStream = null;Scanner scnr = new Scanner(inputStream); //Do not modify this line of code/*** Part c* Using a loop and the Scanner object provided, read the names from Names.txt* and store them in NameList created in Part a.*//*** Part d* Reorder the…arrow_forward
- Each of the following files in the Chapter.10 folder of your downloadable student files has syntax and/or logical errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded with Fixed. For example, DebugTen01.cs will become FixedDebugTen01 .cs. a. DebugTen01.cs b. DebugTen02.cs c. DebugTen03.cs d. DebugTen04.csarrow_forwardEach of the following files in the Chapter.04 folder of your downloadable student files has syntax and/or logical errors. In each case, determine the problem, and fix the program. After you correct the errors, save each file using the same filename preceded with Fixed. For example, save DebugFour1.cs as FixedDebugFour1.cs. a. DebugFour1.cs b. DebugFour2.cs c. DebugFour3.cs d. DebugFour4.csarrow_forwardEach of the following files in the Chapter.01 folder of your downloadable student files has syntax and/or logical errors. In each case, determine the problem and fix the program. After you correct the errors, save each file using the same filename preceded with Fixed. For example, DebugOne1.cs will become FixedDebugOne1 .cs. a. DebugOne1.cs b. DebugOne2.cs c. DebugOne3.cs d. DebugOne4.csarrow_forward
- Each of the following files in the Chapter.07 folder of your downloadable student files has syntax and/or logical errors. In each case, determine the problem, and fix the program. After you correct the errors, save each file using the same filename preceded with Fixed. For example, DebugSeven1.cs will become FixedDebugSeven1.cs. a. DebugSeven1.cs b. DebugSeven2.cs c. DebugSeven3.cs d. DebugSeven4.csarrow_forwardEach of the following files in the Chapter.05 folder of your downloadable student files has syntax and/or logical errors. In each case, determine the problem, and fix the program. After you correct the errors, save each file using the same filename preceded with Fixed. For example, save DebugFive1.cs as FixedDebugFive1 .cs. a. DebugFive1.cs b. DebugFive2.cs c. DebugFive3.cs d. DebugFive4.csarrow_forwardA Java Practical Assignments.pdf - Adobe Acrobat Pro DC (32-bit) File Edit View E-Sign Window Help Home Tools Java Practical Assig. x Sign In 1 /1 139% Java Practical Assignments 1. Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative value. Prompt the user for an input value and try the Math.sqrt() method on it. The application either displays the square root or catches the thrown Exception and displays an appropriate message. 2. Create a program that allows a user to input customer records (ID number, first name, last name, and balance owed) and save each record to a file. 3. Write an application for Limpopo's Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that corresponds to one of the options, and display the option and its price as R250, R220, R150, or R50, accordingly. Display an error message if the…arrow_forward
- Creating Enumerations In this section, you create two enumerations that hold colors and car model types. You will use them as field types in a Car class and write a demonstration program that shows how the enumerations are used. 1. Open a new file in your text editor, and type the following Color enumeration: enum Color {BLACK, BLUE, GREEN, RED, WHITE, YELLOW}; 2. Save the file as Color.java. 3. Open a new file in your text editor, and create the following Model enumeration: enum Model {SEDAN, CONVERTIBLE, MINIVAN}; 4. Save the file as Model.java. Next, open a new file in your text editor, and start to define a Car class that holds three fields: a year, a model, and a color. public class Car { private int year; private Model model; private Color color; 5. Add a constructor for the Car class that accepts parameters that hold the values for year, model, and color as follows: public Car(int yr, Model m, Color c) { year = yr; model = m; color = c; } 6. Add a display()…arrow_forwardJavaarrow_forwardStarting Out with Java From Control Structures through Objects 6th Editionarrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT