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;
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
Related questions
Question
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
This is a popular solution!
Step by step
Solved in 2 steps
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education