Jump to content

help me please : pseudo code

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
9 replies to this topic

#1
declaration19

declaration19

    Newbie

  • Members
  • Pip
  • 5 posts
Hey I am new here, I would like you to help me with a question, that is to be tested on java...

design a pseudo code that will read customer number, name, address, postcode and total amount owing, and - produce a report showing the customer's minimum amount due. The minimum amount due is calculated on the amount owing, as follows:

If the total amount owing is less than $5.00, the total amount owing becomes the minimum amount due. If the total amount owing is greater than $5.00, the amount due is calculated to be one quarter of the total amount owing, provided this resulting amount is not less than $5.00. If the resulting amount is less than $5.00, the minimum amount due is $5.00.

let me see you analyse this and i would show you how i learnt how to do.:closedeyes:

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Moved to the correct forum.

This isn't a hard problem at all. There are much harder problems here: Project Euler
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
declaration19

declaration19

    Newbie

  • Members
  • Pip
  • 5 posts

WingedPanther said:

Moved to the correct forum.

This isn't a hard problem at all. There are much harder problems here: Project Euler

CAN you solve it for me please...i am going on the site you sent me...

#4
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
I'm not understanding why you need someone to solve this for you. Pseudo code is basically you writing out the steps you would take to solve the problem. No real code is needed. Are you not sure how this would be programmed at all?
-CDG10620
Software Developer

#5
declaration19

declaration19

    Newbie

  • Members
  • Pip
  • 5 posts
Yes I am new at it, and sometimes I am a bit unsure. I would like help and someone to check my codes for me. I have a little understanding of pseudo code. I am learning IF THEN ELSE, ENDIF and CASEOF. I am not asking for your answer I am just in need of someone to check my codes, please.

An architect’s fee is calculated as base fee plus a percentage of the cost of a building. The fee is determined as follows:
• A base fee of $1000 PLUS
• 8% of the first $5000 of the building PLUS
o 3 % on the excess of $5000, if this amount is less than or equal to $80,000 OR
o 2 ½% on the amount in excess of $5000, if this amount is more than $80,000
Design a program, using pseudocode, which will accept the cost of the building and calculate and display the architect’s fee.
BEGIN
Declare as real: architect’s fee, cost_of_building
IF amount <= 80,000 THEN
0.03 * 5000
ELSE
IF amount > 80,000 THEN
0.025 * 5000
ENDIF
ENDIF
architect’s_fee=1000= (0.08 * 5000)
cost_of_building = 0.08 *5000
print architect’s_fee
END

Can you tell me what flaws you see in this please. I am practicing so that I can do it properly!

#6
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts
A couple of things.

1. Learn how to space your if statements for easy reading like this

IF( <!-- Condition --> )
{
    <!-- Do Something -->
}
ELSE IF( <!-- Condition --> )
{
    IF( <!-- Condition --> )
    {
        <!-- do something -->
    }
}

2. I don't think that your math on this is going to be correct. Try using variables to hold values that are needed and figure out the actual fee and cost of building based on the requirements that were stated.

Let me know if you need any clarification on this.
-CDG10620
Software Developer

#7
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts

declaration19 said:

Yes I am new at it, and sometimes I am a bit unsure. I would like help and someone to check my codes for me. I have a little understanding of pseudo code. I am learning IF THEN ELSE, ENDIF and CASEOF. I am not asking for your answer I am just in need of someone to check my codes, please.

An architect’s fee is calculated as base fee plus a percentage of the cost of a building. The fee is determined as follows:
• A base fee of $1000 PLUS
• 8% of the first $5000 of the building PLUS
o 3 % on the excess of $5000, if this amount is less than or equal to $80,000 OR
o 2 ½% on the amount in excess of $5000, if this amount is more than $80,000
Design a program, using pseudocode, which will accept the cost of the building and calculate and display the architect’s fee.
BEGIN
Declare as real: architect’s fee, cost_of_building
IF amount <= 80,000 THEN
0.03 * 5000
ELSE
IF amount > 80,000 THEN
0.025 * 5000
ENDIF
ENDIF
architect’s_fee=1000= (0.08 * 5000)
cost_of_building = 0.08 *5000
print architect’s_fee
END

Can you tell me what flaws you see in this please. I am practicing so that I can do it properly!
1) You must store every calculation in a variable if you want to do something with it later.
2) start by doing this by hand. For example, if you make $100,000, then your fee is:
$1000 +
0.08*$5000 + //8% of the first 5000
0.025*($100,000-$5000) //2.5% of the excess
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#8
declaration19

declaration19

    Newbie

  • Members
  • Pip
  • 5 posts
i try spacing it out...it was not so jumbled up. Hold values, ok when you say hold values what do you mean by that, my teacher must have forgotten to mention what that means..
Did I calculate incorrectly? Or did I miss out a calculation?
oh i saw my mistake
architect’s_fee=1000= (0.08 * 5000) its suppose to be 1000+(0.08 *5000) and then it would be the architects fee.
Did i print the correct variable after all the question did say to display the architects fee.
I would just like to know one thing though how are my IF THEN ELSE statements, did i do all right? Besides the lining up of the IF's and everything I know how to indent:)

#9
declaration19

declaration19

    Newbie

  • Members
  • Pip
  • 5 posts
I don't understand the code you gave me, it's nothing like I've learn in school. Its either my teacher wants us to go slow. As a matter of fact the name of my course is Program design I guess its like a introductory to programming we having done any real programming on computer or anything. Sounds suck ish does it? So would you mind clarifying what you told me before please. and thanks for replying!:cool:

#10
cdg10620

cdg10620

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 389 posts

declaration19 said:

I don't understand the code you gave me, it's nothing like I've learn in school. Its either my teacher wants us to go slow. As a matter of fact the name of my course is Program design I guess its like a introductory to programming we having done any real programming on computer or anything. Sounds suck ish does it? So would you mind clarifying what you told me before please. and thanks for replying!:cool:

The code that I put in previously was just to show you how to write If.. Else statements out. the text inside that looked like this <!-- something here --> is just a comment. The "<!--" shows the beginning of the comment and the "-->" shows the end of the comment. I was not going to bother writing out all of the logic. I just wanted to show you how the if... else statements are supposed to be written out so that you and others can understand the flow of your code better. :) Don't feel bad about moving slow. There's nothing wrong with that. Follow WingedPanther's advice. He's a pro for a reason. ;)
-CDG10620
Software Developer