Starting from:

$30

CSE1242-Homework 2 Solved

Write a program that checks ISBN-10. An ISBN-10 (International Standard Book Number) consists of 10 digits: ABCDEFKLMN. The last digit, Z, is a checksum, which is calculated from the other nine digits using the following formula:
 

(𝐴 × 1 + 𝐵 × 2 + 𝐶 × 3 + 𝐷 × 4 + 𝐸 × 5 + 𝐹 × 6 + 𝐾 × 7 + 𝐿 × 8 + 𝑀 × 9) % 11

If the checksum is 10, the last digit is denoted as X according to the ISBN-10 convention. Write a program that prompts the user to enter the first 9 digits and displays the 10-digit ISBN (including leading zeros). Your program should read the input as an integer.

 

 

Sample Run 1:

Enter the first 9 digits of an ISBN as integer: 013601267

The ISBN-10 number is 0136012671

 

 

Sample Run 2:

Enter the first 9 digits of an ISBN as integer: 013031997 The ISBN-10 number is 013031997X

 

 

 

Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is
26(𝑚 + 1)                   𝑦        𝑐

𝑑 = (𝑓 +  + 𝑦 +                      +         + 5𝑐) % 7

4        4

where

d is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday).
f is the day of the month.
m is the month (3: March, 4: April, …, 12: December). January and February are counted as months 13 and 14 of the previous year.
c is the century (i.e., year / 100).
y is the year of the century (i.e., year % 100).
Note that the division in the formula performs an integer division. Write a program that prompts the user to enter a year, month, and day of the month, and displays the name of the day of the week.

(Hint: January and February are counted as 13 and 14 in the formula, so you need to convert the user input 1 to 13 and 2 to 14 for the month and change the year to the previous year.)

Sample Run 1:

Enter year (e.g. 2012): 2015

Enter month (e.g. 1-12): 1

Enter the day of the month (e.g. 1-31): 25

Day of the week is Sunday

 

 

Sample Run 2:

Enter year (e.g. 2012): 2012

Enter month (e.g. 1-12): 5

Enter the day of the month (e.g. 1-31): 12

Day of the week is Saturday

 

 

 

3)  Write a program that calculates personal income tax based on the given tax rates reported by The Turkish Revenue Administration. The tax rates vary every year. Tax rates, which vary each year, are given in the following tables for the last 4 years (i.e., 2020, 2019, 2018, and 2017).

 

Table 1: Turkey Income Tax Calculation for year 2020
Income (TL)
Tax Rate
Tax Calculation
Tax Calculation (Simplified)
income < 22,000
15%
income*15%
income*15%
income < 49,000
20%
22,000*15% + (income-22,000)*20%
3,300 + (income-22,000)*20%
income < 180,000
27%
22,000*15% + 27,000*20% + (income-

49,000)*27%
8,700 + (income-49,000)*27%
income < 600,000
35%
22,000*15% + 27,000*20% +131,000*27%

+ (income-180,000)*35%
44,070 + (income-180,000)*35%
income >= 600,000
40%
22,000*15% + 27,000*20% +131,000*27%

+ 420,000*35% + (income-600,000)*40%
191,070 + (income-600,000)*40%
 

 

The rules for Table 1 are as follows:

If the income is below 22,000 TL, then this amount will be taxed at rate 15%.
If the income is below 49,000 TL, then the first 22,000 TL is taxed at rate 15% (3,300 TL), and the remaining will be taxed at rate 20%.
If the income is below 180,000 TL; the first 22,000 TL is taxed at rate 15% (3,300 TL), then next 27,000 TL is taxed at rate 20% (5,400 TL) which makes 8,700 TL as a total, and the remaining will be taxed at rate 27%.
If the income is below 600,000TL; the first 22,000 TL is taxed at rate 15% (3,300 TL), then next 27,000 TL is taxed at rate 20% (5,400 TL), then next 131,000 TL is taxed at rate 27% (35,370 TL) which makes 44,070 TL as a total, and the remaining will be taxed at rate 35%.
If the income is equal or above 600,000TL; the first 22,000 TL is taxed at rate 15% (3,300
TL), then next 27,000 TL is taxed at rate 20% (5,400 TL), then next 131,000 TL is taxed at

rate 27% (35,370 TL), then next 420,000 TL is taxed at rate 35% (147,000 TL) which makes 191,070 TL as a total, and the remaining will be taxed at rate 40%.

Examples for income -> tax pairs in TL: 20,000 -> 3,000; 32,000 -> 5,300; 149,000 -> 35,700; 280,000 -> 79,070; 700,000 -> 231,070.
Applying similar rules, the tax calculation tables for years 2019, 2018, and 2017 are given in Table 2, 3, and 4, respectively.

Table 2: Turkey Income Tax Calculation for year 2019
Income (TL)
Tax Rate
Tax Calculation (Simplified)
income < 18,000
15%
income*15%
income < 40,000
20%
2,700 + (income-18,000)*20%
income < 148,000
27%
7,100 + (income-40,000)*27%
income < 500,000
35%
36,260 + (income-148,000)*35%
income >= 500,000
40%
159,460 + (income-500,000)*40%
 

 

Table 3: Turkey Income Tax Calculation for year 2018
Income (TL)
Tax Rate
Tax Calculation (Simplified)
income < 14,800
15%
income*15%
income < 34,000
20%
2,220 + (income-14,800)*20%
income < 120,000
27%
6,060 + (income-34,000)*27%
income >= 120,000
35%
29,280 + (income-120,000)*35%
 

 

Table 4: Turkey Income Tax Calculation for year 2017
Income (TL)
Tax Rate
Tax Calculation (Simplified)
income < 13,000
15%
income*15%
income < 30,000
20%
1,950 + (income-13,000)*20%
income < 110,000
27%
5,350 + (income-30,000)*27%
income >= 110,000
35%
26,950 + (income-110,000)*35%
 

 

The user will enter the values of year and income, and your program will first read these values and will report the income, the total tax amount, the income after tax, and the actual tax rate applied to the income. Actual tax rate will be calculated as tax amount divided by income.

 

Sample Run 1:

2015 25000

Undefined year value

 

 

Sample Run 2:

2020 0 Income must be > 0 Sample Run 3:

2020 20000

Income: 20000.0

Tax amount: 3000.0

Income after tax: 17000.0

Real tax rate: 15.0%

 

 

Sample Run 4:

2020 40500.75

Income: 40500.75

Tax amount: 7000.15

Income after tax: 33500.6

Real tax rate: 17.28%

 

 

Sample Run 5:

2019 123456

Income: 123456.0

Tax amount: 29633.12

Income after tax: 93822.88

Real tax rate: 24.0%

 

 

Sample Run 6:

2018 456789

Income: 456789.0

Tax amount: 147156.15

Income after tax: 309632.84

Real tax rate: 32.21%

 

 

Sample Run 7:

2017 145500.75

Income: 145500.75

Tax amount: 39375.26

Income after tax: 106125.48

Real tax rate: 27.06%

 

 

IMPORTANT NOTES
Write a comment at the beginning of each program to explain the purpose of the program. Write your name and student ID as a comment. Include necessary comments to explain your actions.
Select meaningful names for your variables.
You are allowed to use the materials that you have learned in lectures and labs. Do not use the ones that you have not learned in the course.
The outputs of your programs must be the same as the sample runs above.
Please be sure that your programs run properly on any computer.
Your program will be tested with an auto-grader. So, it should take the input exactly the same in the example and it should print the output exactly the same in the example. Otherwise, your program may fail.
You should exactly print the outputs with 2 digits after the decimal point.
You should not print any messages before input taking.
Your program should execute correctly for different test cases.
Please do not write any package name at the beginning of your code!
Selected parts of your codes may be graded; therefore, send a complete solution for the homework; otherwise, you may get a zero-grade based on our evaluation.
Please zip all your files into a single zip file using file naming convention StudentID_HW2.zip, e.g., 150120123_HW2.zip. Your zip file should contain the followings: a) Java source code for Problem 1 (HW2_StudentID_P1.java)Java class file for Problem 1 (HW2_StudentID_P1.class
Java source code for Problem 2 (HW2_StudentID_P2.java)
Java class file for Problem 2 (HW2_StudentID_P2.class
Java source code for Problem 3 (HW2_StudentID_P3.java)
Java class file for Problem 3 (HW2_StudentID_P3.class)
Submit your zip file to http://ues.marmara.edu.tr before deadline.
You are responsible for making sure you are turning in the right file, and that it is not corrupted in anyway. We will not allow resubmissions if you turn in the wrong file, even if you can prove that you have not modified the file after the deadline.
Each student should submit his/her own homework. You can discuss with your peers about the homework, but you are not allowed to exchange codes or pseudocodes. This also applies to material found on the web. If some submitted homework assignments are found to be identical or suspected to be identical, all involved parties will get a grade of ZERO from all homework. You should submit your own work. In case of any forms of cheating or copying, both giver and receiver are equally culpable and suffer equal penalties. All types of plagiarism will result in FF grade from the course.
No late submissions will be accepted.

More products