• 0

help with pseudocode


Question

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:

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

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?

Link to comment
Share on other sites

  • 0
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.

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

  • 0


// 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 }

}

Link to comment
Share on other sites

This topic is now closed to further replies.