Design a program using psuedocode to accept :name, gross salary, personal status, number of children (50employees)
Calculate and print: name, gross salary, income tax for all
Rules: personal allowance $12000 single person $23,000 married. child allowance $1000 per child. Taxabl;e income gross salary- personal allowance and child allowance.
Income tax RUles
10000 and under= no tax
greater than 10000 less than 20000 =20%
greater than 20000, less than 40000 = 30%
above 40000 = 40%

OK guys here's what i have

Start
Declare name, salary, status, children, allowance, taxable_income, income_tax, child_allowance
For 1 to 50
Write "name"
Read Name
Write "gross salary"
Read salary
Write "personal status (married/single)"
Read status
Write "number of children"
Read child
If status=single THEN
Allowance=$12000
ELSE
Allowance=$23000
ENDIF
child_allowance = $1000*child
taxable_income = gross_salary-(Allowance+child_allowance)
If taxable_income =< 10000 THEN
Write "no tax deducted"
ELSE
If taxable_income >10000 and <20000 THEN
income_tax =.20*taxable_income
ELSE
If taxable_income >20000 and <40000 THEN
income_tax = .30*taxable_income
ELSE
If taxable_income > 40000 THEN
income_tax = .40*taxable_income
ENDIF
ENDIF
ENDIF
Write “The person’s name is” name
Write “The person’s gross_salary is” salary
Write “The persons Income Tax is” income_tax
ENDFOR
STOP

Dani AI

Generated

Quick, practical corrections and clarifications based on the thread. The overall flow in 's draft is fine, but there are a few reliability and style fixes to add: keep variable names consistent (pick gross_salary or salary, not both), initialize or reset income_tax and child_allowance at the start of each employee iteration so values don't carry over, and validate inputs (salary ≥ 0, children an integer ≥ 0, status spelled/checked consistently). 's point about consistent casing/keywords is important if the submission must follow a specific pseudocode style.

Resolve the ambiguous bracket boundaries (this answers ). Adopt one clear convention and document it. A common, unambiguous choice is to make the upper bound inclusive: taxable ≤ 10000 → 0%; 10000 < taxable ≤ 20000 → 20%; 20000 < taxable ≤ 40000 → 30%; taxable > 40000 → 40%. Under that convention a taxable income of exactly 20000 is taxed at 20%.

A compact, robust decision pattern to implement inside the loop:

taxable = max(0, gross_salary - allowance - child_allowance)
if taxable <= 10000:
    income_tax = 0.00
elif taxable <= 20000:
    income_tax = round(0.20 * taxable, 2)
elif taxable <= 40000:
    income_tax = round(0.30 * taxable, 2)
else:
    income_tax = round(0.40 * taxable, 2)

Final checklist before submission: clamp taxable to zero, initialize per-employee variables, use a fixed rounding strategy (two decimals or integer cents/Decimal type), print a consistent output format (show 0.00 rather than an empty “no tax” where required), and document the inequality convention you chose so graders (and future readers) know how exact cutoffs are handled.

Recommended Answers

All 6 Replies

Do you need to pay attention to case? Your variable declarations don't all match variables in the pseudo-code (allowance versus Allowance, why "Start" but "STOP", "If" but "ENDIF", "Declare" and not "DECLARE"?)

Do you need to pay attention to case? Your variable declarations don't all match variables in the pseudo-code (allowance versus Allowance, why "Start" but "STOP", "If" but "ENDIF", "Declare" and not "DECLARE"?)

Here's the correction
Start
DECLARE name, salary, status, children, allowance, taxable_income, income_tax, child_allowance
FOR 1 to 50
WRITE "name"
READ Name
WRITE "gross salary"
READ salary
WRITE "personal status (married/single)"
READ status
WRITE "number of children"
READ child
IF status=single THEN
allowance=12000
ELSE
allowance=23000
ENDIF
child_allowance = 1000*child
taxable_income = gross_salary-(allowance+child_allowance)
IF taxable_income =< 10000 THEN
WRITE "no tax deducted"
ELSE
IF taxable_income >10000 and <20000 THEN
income_tax =.20*taxable_income
ELSE
IF taxable_income >20000 and <40000 THEN
income_tax = .30*taxable_income
ELSE
income_tax = .40*taxable_income
ENDIF
ENDIF
ENDIF
WRITE “The person’s name is” name
WRITE “The person’s gross_salary is” salary
WRITE “The persons Income Tax is” income_tax
ENDFOR
STOP

overall does it seem correct?

Well, overall it seems at least reasonably correct. I've never cared to do pseudo code myself: I just code a simple frame of what I need, then add testing and actual code until it is all done. Since you have to do it to your prof's standards, I'm really not a good resource for that. But the flow is appropriate.

Well, overall it seems at least reasonably correct. I've never cared to do pseudo code myself: I just code a simple frame of what I need, then add testing and actual code until it is all done. Since you have to do it to your prof's standards, I'm really not a good resource for that. But the flow is appropriate.

.lol ok thnks

What tax do you pay if your income after deductions is exactly 20000?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.