Jump to content
Sign in to follow this  
Followers 0

help with pseudocode


7 posts in this topic

Posted

I need some help

Can you guys help me write a pseudocode, please?

Here's the problem:

Consider the following description of a problem

 

A company intends to offer a salary increase in accordance with the position of each employee, as the following table

position  --    raise

manager -->         5%
engineer ->        25%
technician ->      40%


develop an algorithm that reads the salary and job code of a employe and calculate the new salary.

if the position of the employee is not in the table, it must receive an increase of 50%. in the end, the algorithm should indicate the old salary, new salary and the difference between them.

present an algorithm using the Structure IF

 

and they ask for another algorytm for the Case Structure

 

any help please :cry:

Share this post


Link to post
Share on other sites

Posted

What is your question?

Share this post


Link to post
Share on other sites

Posted

What is your question?

I'm trying to write the algorithm for that problem, asik.

 

i'm taking code classes and i still have a lot to learn.

 

can you help me generate a code for that particular problem, using the structure IF? and another algorithm for the same problem, using the structure case?

Share this post


Link to post
Share on other sites

Posted

IF (Person.Role == Role)
{
Wage.Difference = Wage.Initial * Role.Raise
Wage.Final = Wage.Initial + Wage.Difference
}
ELSE
{
Wage.Difference = Wage.Initial * 0.5
Wage.Final = Wage.Initial + Wage.Difference
}

That's how I'd write it, but depends on how they've taught you to write pseudo code.

Share this post


Link to post
Share on other sites

Posted

It is just a simple conditional algorithm ->

read What's your position?
read What's your current salary?

if (Position = Manager) {
NewSalary = CurrentSalary * (1 + 5/100)
} else if (Position = Engineer) { 
NewSalary = CurrentSalary * (1 + 25/100)
} else if ... {

} else {
NewSalary = CurrentSalary * (1 + 50/100)
}

DiffSalary = NewSalary - CurrentSalary

print CurrentSalary
print NewSalary
print DiffSalary

with "case" it is practically the same  just change the conditional with something like this

case Position of
Manager: NewSalary = CurrentSalary * (1 + 5/100)
Engineer: NewSalary = CurrentSalary * (1 + 25/100)
...
default: NewSalary = CurrentSalary * (1 + 50/100)

endcase

Cheers

Share this post


Link to post
Share on other sites

Posted

I'm trying to write the algorithm for that problem, asik.

 

i'm taking code classes and i still have a lot to learn.

 

can you help me generate a code for that particular problem, using the structure IF? and another algorithm for the same problem, using the structure case?

I understand you want help with that, but you didn't ask a question, so short of providing you with a complete answer to your assignment I don't know what to say. Do you not understand what is an If structure, i.e.

if [condition] then
     (...)
else if [other condition] then
     (...)
else
     (...)

? Or a switch-case statement? I can only guess at what you don't understand, if you don't point it out.

Share this post


Link to post
Share on other sites

Posted

// raise amounts as decimals
 
var manager_raise = 1.05
var engineer_raise = 1.25
var technician_raise = 1.40
 
foreach (employee in company) {
  if (employee.job == "manager") { employee.wage *= manager_raise }
  elseif (employee.job == "engineer") { employee.wage *= engineer_raise }
  elseif (employee.job == "technician") { employee.wage *= technician_raise }
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.