Assume you have written a Java program… Solved

20.00 $

Categories: ,
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: docx solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (7 votes)

Java programs tend to have three types of errors: javac compiler errors, syntax errors, or logic errors. Javac errors are usually related to misspelled commands, filenames, or improper installation of Java, whereas syntax errors are generated by the compiler. When you compile a program, sometimes one syntax error may generate multiple error messages and sometimes multiple syntax errors may generate only one error message. Programs with logic errors will compile cleanly but will not provide the correct output for a given input. These logic errors are often more difficult to find and fix than syntax errors.

In programming, there are many strategies available for solving such errors or problems. The five-step approach is one of the most common. These five steps include:

  1. Specify the problem—identify the problem as specifically as possible. Be sure to include details of what you want to accomplish (the goal state).
  2. Analyze the problem—learn as much as you can about the problem. Some techniques that can be used in this step include brainstorming, research, and talking to other people about the problem.
  3. Develop a set of possible solutions—usually there is more than one way to solve a problem. Using the same techniques as in Step 2, think of possible solutions. It often helps to consider how you solved similar problems in the past.
  4. Evaluate possible solutions—weigh the strengths and limitations of each solution you discovered in Step 3.
  5. Choose a solution—consider several factors such as time required, financial cost, practicality, and so forth.

When you write a Java program in this course, you typically start with a template that you have copied and pasted from a previous program into your Java editor. You then modify this template to create the code you need. Usually, the code will start with some information that is input into the program (via user keyboard input for simple programs or later by reading a data file). The program then processes the information and creates output (once again, simple programs send output to the screen, more complex programs may send output to the file and error messages or confirmation messages to the screen).

For this Discussion:

Assume you have written a Java program that takes four input variables (integerOne, integerTwo, integerThree, integerFour) and calculates an output variable (resultOut) using the following formula: resultOut = (integerOne + integerTwo) * integerThree – integerFour .

Using your text and/or the Internet as a resource, list three different types of syntax errors the Java compiler may find in your program. Then, use the five problem-solving steps listed above to determine how you will fix each type of error. Be sure to clearly highlight the five steps within your posting.

Finally, assume your program compiles cleanly with no syntax errors. You input the values 2, 3, 4, 5 and the valueOut is computed to be 17 (it should be 15). Specify how you will use the five problem-solving steps to find the logic error.

  • Answer-2.docx