Choose the line of code that has the logic error: /** * Simple linear income tax calculator based on preset rates and threshold levels. * @author Hyrum D. Carroll * @version 0.1 (September 3, 2019) */ public class TaxCalculator{ private double tax; // annual income in dollars // Line 2 private final double LEVEL 1 INCOME = 10 000.00; private final double LEVEL 2 INCOME = 50 000.00; private final double LEVEL 3 INCOME = // Line 4 // Line 5 100 000.00; // Line 6 // of income private final double TAX RATE 1 = 0.103; private final double TAX RATE 2 = 0.15; private final double TAX RATE 3 = 0.2o; private final double TAX RATE 4 = 0.30; // Line 9 // Line 10 // Line 11 // Line 12 /** * Calculates the amount of taxes due * * Calculations are // Line 14 // Line 15 // Line 16 // Line 17 // Line 18 // Line 19 // Line 20 // Line 21 // Line 22 // Line 23 // Line 24 // Line 25 // Line 26 // Line 27 // Line 28 // Line 29 // Line 30 // Line 31 // Line 32 // Line 33 // Line 34 // Line 35 // Line 36 // Line 37 as follows: *10% if income is less than $10,000 * 15% if income is less than $50,000 *20% if income is less than $100, 000 * 30% otherwise income * income * income income @param income The amount of income in dollars * @return The amount of taxes due : */ public double getTax( double income ){ if ( income < LEVEL 1 INCOME) { tax = income TAX RATE 1; }else if( income < LEVEL 2 INCOME ) { tax = income * TAX RATE 2; Jelse if( income < LEVEL 2 INCOME ) { tax = income * TAX RATE_3; }else{ tax = income TAX_RATE_4; tax = Math.round ( tax * 100.0) / 10o.0; return tax;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Choose the line of code that has the logic error:
/**
* Simple linear income tax calculator based on preset rates and threshold levels.
* Gauthor Hyrum D. Carroll
* @version 0.1 (September 3, 2019)
public class TaxCalculator(
private double tax;
W annual income in dollars
// Line 2
private final dowble LEVEL 1 INCOME
private final double LEVEL 2 INCOME
private fiinal double LEVEL 3 INCOME = 10o o00.00; // Line 6
= 10 000.00;
50 000.0%;
/ Line 4
// Line 5
// of income
private final double TAX RATE 1 = 0.10:
private final double TAX RATE 2
private final double TAX RATE 3 = 0.20;
private final double TAX RATE 4
// Line 9
// Line 10
// Line 11
// Line 12
0.15;
0.30;
%3!
**
//Line 14
// Line 15
//Line 16
//Line 17
// Line 18
WLine 19
// Line 20
// Line 21
/W Line 22
// Line 23
// Line 24
/ Line 25
//Line 26
// Line 27
// Line 28
// Line 29
/ Line 30
// Line 31
// Line 32
// Line 33
/ Line 34
// Iine 35
// Line 36
// Line 37
* Calculates the amount of taxes due
<p>
* Calculations are as follows:
* income
10 if income is less than S10,000
15% if income is less than $50,000
20 1f income is Less than S100, 000
* 30% otherwise
income
income
* income
* </p>
* @param income The amount of income in dollars
* @return The amount of taxes due:
public double getTax( double income)(
if ( income < LEVEL 1 INCOME ) {
* TAX RATE 1;
tax
income
}else if( income < LEVEL 2 INCOME ){
income * TAX RATE 2;
Delse if( income < LEVEL 2 INCOME ) {
tax
tax
income
* TAX RATE 3;
Delse{
tax =
income * TAX RATE 4;
tax = Math.round (tax * 100.0) / 10o.0:
return tax;
Transcribed Image Text:Choose the line of code that has the logic error: /** * Simple linear income tax calculator based on preset rates and threshold levels. * Gauthor Hyrum D. Carroll * @version 0.1 (September 3, 2019) public class TaxCalculator( private double tax; W annual income in dollars // Line 2 private final dowble LEVEL 1 INCOME private final double LEVEL 2 INCOME private fiinal double LEVEL 3 INCOME = 10o o00.00; // Line 6 = 10 000.00; 50 000.0%; / Line 4 // Line 5 // of income private final double TAX RATE 1 = 0.10: private final double TAX RATE 2 private final double TAX RATE 3 = 0.20; private final double TAX RATE 4 // Line 9 // Line 10 // Line 11 // Line 12 0.15; 0.30; %3! ** //Line 14 // Line 15 //Line 16 //Line 17 // Line 18 WLine 19 // Line 20 // Line 21 /W Line 22 // Line 23 // Line 24 / Line 25 //Line 26 // Line 27 // Line 28 // Line 29 / Line 30 // Line 31 // Line 32 // Line 33 / Line 34 // Iine 35 // Line 36 // Line 37 * Calculates the amount of taxes due <p> * Calculations are as follows: * income 10 if income is less than S10,000 15% if income is less than $50,000 20 1f income is Less than S100, 000 * 30% otherwise income income * income * </p> * @param income The amount of income in dollars * @return The amount of taxes due: public double getTax( double income)( if ( income < LEVEL 1 INCOME ) { * TAX RATE 1; tax income }else if( income < LEVEL 2 INCOME ){ income * TAX RATE 2; Delse if( income < LEVEL 2 INCOME ) { tax tax income * TAX RATE 3; Delse{ tax = income * TAX RATE 4; tax = Math.round (tax * 100.0) / 10o.0: return tax;
Expert Solution
Step 1

For income less than $100.000 i.e LEVEL_3_INCOME, the TAX_RATE is 0.20.

In line 31 and 32, the condition written is

else if( income < LEVEL_2_INCOME)

{

          tax = income * TAX_RATE_3;

}

is wrong.

Line 31 has a logical error.

 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education