184k views
2 votes
Jim is writing a program to calculate the wages of workers in a teddy bear factory.

The wages earned by a worker is either £2 for every teddy bear they have made or £5 for every hour they have worked, whichever is larger.

Write an algorithm that:
• allows the user to input the number of teddy bears made and the number of hours worked
• calculates the wages for the number of teddy bears made
• calculates the wages for the number of hours worked
• outputs the larger of the two results.

User Gnerkus
by
3.4k points

1 Answer

5 votes

Answer:

The algorithm is as follows;

1. Start

2. Input TeddyBears

3. Input Hours

4. WagebyTeddy = 2 * TeddyBears

5. WagebyHour = 5 * Hours

6. If WagebyHour > WagebyTeddy then

6.1 Print WagebyHour

7. Else

7.1. Print WagebyTeddy

8. Stop

Step-by-step explanation:

The following variables are used;

TeddyBears -> Number of teddy bears made

Hours -> Number of Hours worked

WagebyTeddy -> Wages for the number of teddy bears made

WagebyHour -> Wages for the number of hours worked

The algorithm starts by accepting input for the number of teddy bears and hours worked from the user on line 2 and line 3

The wages for the number of teddy bears made is calculated on line 4

The wages for the number of hours worked is calculated on line 5

Line 6 checks if wages for the number of hours is greated than wages for the number of bears made;

If yes, the calculated wages by hour is displayed

Otherwise

the calculated wages by teddy bears made is displayed

User Jecjackal
by
3.6k points