• 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
https://www.neowin.net/forum/topic/1183881-help-with-pseudocode/
Share on other sites

6 answers to this question

Recommended Posts

  • 0
  On 24/10/2013 at 00:13, Asik said:

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?

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

  • 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

  • 0
  On 24/10/2013 at 11:47, natta said:

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.

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

}

This topic is now closed to further replies.
  • Posts

    • If you're stupid enough to try and get one, each and every headache along the way is on you. I can only hope that these roadblocks on a pre-order are enough to dissuade people.
    • "You should have a Microsoft Account because we can help keep your data safe...until we can't." As an IT guy I know that I should never put my trust in one backup solution if the data is important. But for non-IT people, they are getting tricked into Microsoft's practices with falsehoods.
    • it is delayed and has no definitive release date... that is "delayed indefinitely".
    • About that Trump's mobile 🤣🤣🤣  
    • AliExpress faces EU crackdown, makes promises to fight illegal products by Paul Hill The European Commission has taken two significant actions against the Chinese online marketplace AliExpress under the Digital Services Act (DSA) in a bid to enhance user and consumer safety online. The first action was to get AliExpress to commit to several legally binding commitments to address issues related to advertising and recommender systems. The second action was the publication of preliminary findings which found that AliExpress had breached obligations regarding the spread of illegal products. AliExpress can now respond to the Commission but if the broken rules are confirmed then AliExpress can expect to be fined. The Digital Services Act is a new tool that the EU has to regulate large online platforms. It aims to level the business playing field, protect fundamental rights of users, create a safer digital space, and improve transparency from businesses. AliExpress's pledges: More transparency, safer shopping As part of the pledges made by AliExpress, it will do more to monitor and detect illegal products such as medicines, food supplements, and adult material propagated through hidden links and affiliate programs. To help flag illegal items, AliExpress has promised to improve its notice and action mechanism. Other pledges include enhancements to the internal complaint handling system; more transparency for advertising and recommender systems; better traceability of traders on the platform; and improved data access for researchers. By implementing these rules, the European Commission hopes it can make AliExpress safer for registered and non-registered users by limiting the exposure to illegal content. Deep dive into AliExpress's alleged failures With regards to the preliminary findings, the Commission found that AliExpress had underestimated the risks because it had not allocated enough resources to moderation systems for illegal products. It also found that the company had failed to consistently enforce its penalty policy against those publishing illegal content. The Commission also discovered systemic failures in AliExpress’s proactive content moderation systems that allowed malicious traders to continue to operate or start operating on the platform. AliExpress is designated as a Very Large Online Platform (VLOP) which means it has to meet certain standards set out by the EU. The aforementioned violations are against the quality of operation that the EU expects from VLOPs. The company now has the right to defend itself against the EC’s findings, it can examine the documents and reply in writing, but if the findings are confirmed, AliExpress could face fines and be required to submit an action plan.
  • Recent Achievements

    • Week One Done
      TBithoney earned a badge
      Week One Done
    • First Post
      xuxlix earned a badge
      First Post
    • First Post
      Tomek Święcicki earned a badge
      First Post
    • One Year In
      carlitin86 earned a badge
      One Year In
    • Reacting Well
      Peterlll06 earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      674
    2. 2
      ATLien_0
      283
    3. 3
      Michael Scrip
      226
    4. 4
      +FloatingFatMan
      192
    5. 5
      Steven P.
      145
  • Tell a friend

    Love Neowin? Tell a friend!