subject

Task #3 Debugging a Java Program 1. Copy the file Sales Tax. java (see Code Listing 1.2) from the Student CD or as directed by your instructor.
2. Open the file in your IDE or text editor as directed by your instructor. This file contains a simple Java program that contains errors. Compile the program. You should get a listing of syntax errors. Correct all the syntax errors, you may want to recompile after you fix some of the errors.
3. When all syntax errors are corrected, the program should compile. As in the previous exercise, you need to develop some test data. Use the chart below to record your test data and results when calculated by hand.
4. Execute the program using your test data and recording the results. If the output of the program is different from what you calculated, this usually indicates, a logic error. Examine the program and correct any logic errors. Compile the program and execute using the test data again. Repeat until all output matches what is expected?
Item Price Tax Total (calculated) Total (output)
Code Listing 1.2 (SalesTax. java)
import java. util. Scanner; // Needed for the Scanner class
/**
This program calculates the total price which includes sales tax.
*/
public class Sales Tax
{
public static void main(String[] args)
{
// Identifier declarations
final double TAX_RATE = 0.055;
double price;
double tax
double total;
String item;
// Create a Scanner object to read from the keyboard.
Scanner keyboard = new Scanner(System. in); ");
// Display prompts and get input.
System. out. print("Item description:
item= keyboard. nextLine();
System. out. print("Item price: $");
price - keyboard. nextDouble();
// Perform the calculations.
tax = price + TAX_RATE;
totl - price* tax;
// Display the results.
System. out. print (item + " $");
System. out. println(price);
System. out. print("Tax $");
System. out. println(tax);
System. out. print("Total $");
System. out. println (total);
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:30
Why is an outfitting a workspace with video games in a technology development company considered a strategic use of money
Answers: 1
question
Computers and Technology, 24.06.2019 09:30
Retype the statements, correcting the syntax errors. system.out.println("num: " + songnum); system.out.println(int songnum); system.out.println(songnum " songs"); note: these activities may test code with different test values. this activity will perform two tests: the first with songnum = 5, the second with songnum = 9. see how to use zybooks.
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
The program below has been generalized to read a user's input value for hourlywage. run the program. notice the user's input value of 10 is used. modify that input value, and run again. generalize the program to get user input values for workhoursperweek and workweeksperyear (change those variables' initializations to 0). run the program. monthsperyear will never change, so define that variable as final. use the standard for naming final variables. ex: final int max_length
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
In a heat transfer course, we can derive the equation for the temperature distribution in a flat rectangular plate. in this example, we will look at a plate at steadystate with three sides being held at t1, and one side held at t2. the temperature for any location on the plate, t(x,y), can be calculated by where create a function (prob3_5) that will take inputs of vectors x and y in feet, scalar n, scalars l and w in feet and scalars t1 and t2 in degrees fahrenheit. it will output a matrix t which is the temperature of each x and y locations. t will have the number of columns equal to the number of elements in x and rows equal to the number of elements in y. though this can be done without loops (perhaps more efficiently), your program must use a nested loop.
Answers: 2
You know the right answer?
Task #3 Debugging a Java Program 1. Copy the file Sales Tax. java (see Code Listing 1.2) from the S...
Questions
Questions on the website: 13722367