2 Replies - 5890 Views - Last Post: 31 January 2010 - 10:16 AM Rate Topic: -----

#1 rebego  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 17-October 09

writing pseudo-code

Post icon  Posted 29 January 2010 - 03:03 PM

My homework question was:
Write the pseudo-code for an If..Then statement that determines the apropriate tax rate for a given annual income level using the guide below:
Under $20,000 = 2% income tax
$20,000 - $50,000 = 5%
$50,001 - $75,000 = 10%

This is what i wrote:

If Annual Income is < $20,000 Then
income tax = 2%
If Annual Income is $20,000<= $50,000 Then
income tax = 5%
If Annual Income is $50,001 <= $75,000 Then
income tax = 10%

I know this is simple for some but I just want to make sure I'm doing ok. Please advise? Thank you

Is This A Good Question/Topic? 0
  • +

Replies To: writing pseudo-code

#2 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

Re: writing pseudo-code

Posted 29 January 2010 - 03:10 PM

That seems okay - I don't know the syntax of pseudocode, but I think it would be good if you did something like this - and made it seem more code-like.
- Removed spaces from identifiers
- "Fixed" the If statement accoding to VB.NET syntax
- Made values "legal"
- Made it more VB.NET-like

Dim annualIncome as integer = inputbox("What is your annual income?")
Dim incomeTax as integer 

If annualIncome < 20000 Then
incomeTax = 2
ElseIf annualIncome >= 20000 and annualIncome <= 50000 Then
incomeTax = 5
ElseIf annualIncome >= 50001 and annualIncome <= 75000 Then
incomeTax = 10
End If

msgbox("The tax rate for the income " & annualIncome & " is " & incomeTax & "%")



I'll go off to learn the syntax of pseudo code now ^^

This post has been edited by LeisureProgrammer: 29 January 2010 - 03:17 PM

Was This Post Helpful? 0
  • +
  • -

#3 MKunstman  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 193
  • Joined: 26-October 09

Re: writing pseudo-code

Posted 31 January 2010 - 10:16 AM

View Postrebego, on 29 Jan, 2010 - 02:03 PM, said:

My homework question was:
Write the pseudo-code for an If..Then statement that determines the apropriate tax rate for a given annual income level using the guide below:
Under $20,000 = 2% income tax
$20,000 - $50,000 = 5%
$50,001 - $75,000 = 10%

This is what i wrote:

If Annual Income is < $20,000 Then
income tax = 2%
If Annual Income is $20,000<= $50,000 Then
income tax = 5%
If Annual Income is $50,001 <= $75,000 Then
income tax = 10%

I know this is simple for some but I just want to make sure I'm doing ok. Please advise? Thank you

I would say this is fine. You have the concept of what the program would do. If you wanted yes, you could also psuedo in the displays and such but you do not have to. That should be ok.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1