Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,151,766 members, 7,813,543 topics. Date: Tuesday, 30 April 2024 at 01:40 PM |
Nairaland Forum / Science/Technology / Programming / Helepimi Solve This Problem (1895 Views)
PHP Guys Please Help Me Solve This Problem / Programmers help me With This Problem Pls !!!!!!!!!!! / Someone Please Help Solve This Problem. (2) (3) (4)
Helepimi Solve This Problem by NOWORRIES: 11:02am On Mar 27, 2009 |
QUESTION A COMPANY PAYS THEIR EMPLOYEES ON A MONTHLY BASIS. THERE ARE 2 PAYMENT RATES A) NORMAL RATE=N5 AN HOUR FOR WORK BETWEEN 8AM AND 5PM B).OVERTIME RATE=N10 AN HOUR FOR WORK OUTSIDE OF 8AM AND 5PM. PAYMENT IS CALCULATED ON THE NUMBER OF HOURS WORKED. ASSUME THAT DATA IS ENTERED AS 2 FIGURES IN 24 HOUR CLOCK. THE FIRST IS AMN INTEGER THAT INDICATE EMPLOYEE START TIME AND THE SECOND IS FINISH TIME. THE COMPANY ALLOWS NO ONE TO WORK LATER THAN MIDNIGHT. 1.WRITE AN ALGORITHM FOR A PAYROLL SYSTEM TO CALCULATE HOW MUCH AN EMPLOYEE WILL BE PAID IN A MONTH. ASSUME EMPLOYEE WORKS MONDAY TO FRIDAY. ALGORITHM SHOULD ALLOW YOU TO A)INPUT THE HOURS WORKED. B)CALCULATE AMOUNT C) PRINT AMOUNT. THE PROGRAM MUST SATISFY THE FOLLOWING 1. A USER MUST BE PROMPTED TO INPUT DATA IN A CORRECT FORMAT. IF INCORRECT USER MUST BE PROMPTED TO RE-ENTER DATA. 2.PERFORM THE CALCULATION AND INFORM USER OF RESULT |
Re: Helepimi Solve This Problem by Nobody: 1:37pm On Mar 27, 2009 |
what language are u supposed to use? |
Re: Helepimi Solve This Problem by jacob05(m): 2:40pm On Mar 27, 2009 |
Interesting , what language ?? |
Re: Helepimi Solve This Problem by jacob05(m): 2:41pm On Mar 27, 2009 |
Interesting , what language ?? |
Re: Helepimi Solve This Problem by NOWORRIES: 3:33pm On Mar 27, 2009 |
BASICALLY WHAT IS REQUIRED IS TO WRITE AN ALGORITHM SHOWING THAT THE PROGRAM FULFILLS THE REQUIREMENTS NEEDS AND DISCUSS WHY PARTICULAR VARIABLES, LOOPS ETC WERE USED. IT IS FOR A BEGINNER IN PROGRAMMING EMPHASIS IS NOT ON ANY PARTICULAR LANGUAGE |
Re: Helepimi Solve This Problem by NOWORRIES: 3:44pm On Mar 27, 2009 |
BASICALLY WHAT IS REQUIRED IS TO WRITE AN ALGORITHM SHOWING THAT THE PROGRAM FULFILLS THE REQUIREMENTS NEEDS AND DISCUSS WHY PARTICULAR VARIABLES, LOOPS ETC WERE USED. IT IS FOR A BEGINNER IN PROGRAMMING EMPHASIS IS NOT ON ANY PARTICULAR LANGUAGE |
Re: Helepimi Solve This Problem by blinx4real(m): 3:50pm On Mar 27, 2009 |
the language is insinificant, all you need to provide is the algorithm. Basics of computer programming!!! hope u guys didn't learn programming from Computer village? |
Re: Helepimi Solve This Problem by NOWORRIES: 3:56pm On Mar 27, 2009 |
BASICALLY WHAT IS REQUIRED IS TO WRITE AN ALGORITHM SHOWING THAT THE PROGRAM FULFILLS THE REQUIREMENTS NEEDS AND DISCUSS WHY PARTICULAR VARIABLES, LOOPS ETC WERE USED. IT IS FOR A BEGINNER IN PROGRAMMING EMPHASIS IS NOT ON ANY PARTICULAR LANGUAGE |
Re: Helepimi Solve This Problem by yawatide(f): 4:33pm On Mar 27, 2009 |
Yep, its algorithm not language. One can easily do this in pseudocode. I will start, for those who are follow-follow 1) Program should be contained in a loop of some kind. First prompt should obviously be the menu, like so: Start Loop Present Menu: 1) Enter Employee Name 2) Enter Hours Worked 3) Calculate Hours 4) Exit Program Validate Input End Loop Each Step would be captured via a say, switch statement and a function would be called based on number entered. For step 3, I envision a couple constants (for regular pay and overtime pay). I will leave it at that for others to contribute and for poster to hopefully gain motivation to continue. NOTE: There are several ways to do this. This is just the way I envision it. |
Re: Helepimi Solve This Problem by jacob05(m): 4:44pm On Mar 27, 2009 |
But you said in you question to write a program based on the algorithm . |
Re: Helepimi Solve This Problem by jacob05(m): 4:47pm On Mar 27, 2009 |
But you said in you question to write a program based on the algorithm . |
Re: Helepimi Solve This Problem by yawatide(f): 6:24pm On Mar 27, 2009 |
Yes, you can write a program based on an algorithm. Note though that writing a program doesn't imply the use of a particular programming language. IMHO if the language isn't specified, it is safe to say that one could use pseudo code to answer the question. |
Re: Helepimi Solve This Problem by Nobody: 10:53am On Mar 28, 2009 |
no mind me, na 4 under bridge i learn my programming infact, na owode market i buy my pentium I black & white computer. and na firewood fire i dey take power am |
Re: Helepimi Solve This Problem by NOWORRIES: 1:47pm On Mar 28, 2009 |
yawa-ti-de Thanking you very much. |
Re: Helepimi Solve This Problem by ifelekan1(m): 5:35pm On Mar 30, 2009 |
My guy, this is the solution i have for your question. Algorithm is just a step by step logical program statement to solving a program. The Algorithm is as follows Start Set Counter = 0 Set TotalAmount = 0 5 Input(Enter) Hours Worked, Hw If HW <= 10 Then NormalAmount = Hw * 5 TotalAmount = TotalAmount + NormalAmount else Overtime = Hw - 10 NormalAmount = 10 * 5 OvertAmount = Overtime * 10 TotalAmount = NormalAmount +OvertAmount + TotalAmount end if Increment counter by 1 ( counter = counter + 1) If counter > 22 Then go to 10 else go to 5 end if 10 Stop Corrections and contributions are there by welcome. |
Re: Helepimi Solve This Problem by Ibime(m): 12:51pm On Mar 31, 2009 |
ife_lekan: Nice try, but step (b.) is unnecessary as it overrides step (a.). In addition, Hours Worked can be < 10, for example, an employee may only work 8 hours and does not need to be paid for 10, so there is no need to define step (b.) as NormalAmount = 10 * 5. Step (a.) will suffice. Besides, 10 hours is not the normal working time, but 9 hrs (8am - 5pm), therefore replace 10 with 9, with regards to defining Overtime and HW. Otherwise, this is a good job. |
Re: Helepimi Solve This Problem by NOWORRIES: 1:43pm On Mar 31, 2009 |
I throw way salute for all of una for your contribution. I am following step by step |
Re: Helepimi Solve This Problem by Bossman(m): 3:55pm On Mar 31, 2009 |
You have got some good leads and possibly the solution. However, it's critical for your own development and success as a programmer, to attempt to solve this on your own. Then, if you get stuck, you can post here and folks will put you on the right track. In the "real world" you will need to be able to think logically and solve problems. Nobody will be there to provide the solutions to you during an interview either. I am somewhat surprised the folks just jumped in and provided answers without asking you what you have done first. Anyway, this is just my opinion. |
Re: Helepimi Solve This Problem by NOWORRIES: 4:51pm On Mar 31, 2009 |
I will post what I have done so far bossman thanks |
Re: Helepimi Solve This Problem by NOWORRIES: 5:09pm On Mar 31, 2009 |
with the contributions so far i was on the wrong path, and very de motivated about the elementaries of programming. I thank everyone, I will post what I have done so far. |
Re: Helepimi Solve This Problem by Kobojunkie: 12:19am On Apr 01, 2009 |
@Poster, not exactly sure if this is a class assignment or a project you expect to be paid for, but I would like to say that if you really want to do a good job, you would best look at an OOP approach to solving this particular problem. It could earn you extra point in school. If this is not for school, well, it provides you a more atomic model that will aid you in handling what ever may come up next in this. Algorithms seem to work best when the shells you build them on are flexible enough to handle whatever is thrown at them. |
Re: Helepimi Solve This Problem by NOWORRIES: 9:55am On Apr 01, 2009 |
its a class assignment KOBO JUNKIE |
Re: Helepimi Solve This Problem by NOWORRIES: 9:56am On Apr 01, 2009 |
AM STUDYING ON MY OWN DISTANCE LEARNING COURSE |
Re: Helepimi Solve This Problem by ifelekan1(m): 10:58am On Apr 01, 2009 |
Ibime: Thanks Ibime for your contributions and correction, i really appreciate it. Let me really explain the step (b). The step (b) will be executed if the Hours Worked is greater than 9 hours i.e from 8 am - 5pm. and in case the Hours worked is not greater than 10 the step (a) will be executed and the program code move to incrementing the Counter inorder to continue calculation for the next day. The step (b) will be executed if Hours Worked is greater than 9 hours thereby calculating the normal amount for the 9 hours and thereby calculating the Overtime Hours and the Amount for the Overtime hours, now adding the Overtime Amount with the normal 9 hours amount before it continues for the next day. Thanks More contributions are still welcomed. |
Re: Helepimi Solve This Problem by Ibime(m): 1:59pm On Apr 01, 2009 |
With this problem, it is best to run two or three seperate scripts in order to input variables (in the 1st script) so as to make it more 'hands free'. You can then call the function under test (main script) from the 1st script so you do not have to start inputting figures into the main script. You can also have a seperate script for outputting the results if you wish, from where you can then sum up the total wages paid to all employees for the day. I wonder if anyone can write an algorithm to find the total wages for all the employees, without having to do the manual addition of all individual pay packets at the end of the day. To be quite honest, you will save yourself time by solving this problem in Excel. Any algorithm for this problem would still require a lot of human input. |
Re: Helepimi Solve This Problem by Ibime(m): 2:01pm On Apr 01, 2009 |
With this problem, it is best to run two or three seperate scripts in order to input variables (in the 1st script) so as to make it more 'hands free'. You can then call the function under test (main script) from the 1st script so you do not have to start inputting figures into the main script. You can also have a seperate script for outputting the results if you wish, from where you can then sum up the total wages paid to all employees for the day. I wonder if anyone can write an algorithm to find the total wages for all the employees, without having to do the manual addition of all individual pay packets at the end of the day. |
Re: Helepimi Solve This Problem by Ibime(m): 2:02pm On Apr 01, 2009 |
With this problem, it is best to run two seperate scripts in order to input variables (in the 1st script) so as to make it more 'hands free'. You can then call the function under test (main script) from the 1st script so you do not have to start inputting figures into the main script. I wonder if anyone can write an algorithm to find the total wages for all the employees, without having to do the manual addition of all individual pay packets at the end of the day. |
Re: Helepimi Solve This Problem by Ibime(m): 2:20pm On Apr 01, 2009 |
ife_lekan: Oops. I didn't note the 'else', between them. Too much in a hurry. Yep, the script is perfect if we just change 10 to 9 with regards to normal hours. |
Re: Helepimi Solve This Problem by Kobojunkie: 4:06pm On Apr 01, 2009 |
@Poster, what is the primary language for the course? If it is an OOP language, then I suggest you solve this in an OO way. From what I remember of college, the more you apply what you have been taught in solving problems given, the more points you earn, and the better you understand concepts taught and where and how to best apply them. Quick solutions are good , but better solutions are best. |
Re: Helepimi Solve This Problem by NOWORRIES: 9:12am On Apr 02, 2009 |
my post has not yet showed up! I will tyr again Payroll System Start 1. Process Read Data 2. Process Validate Data 3. Process Calculate Amount 4. Process Print Amount End 1.Read Data Print [Please enter Employee Name] Enter [EmployeeName] Print [Please enter the start time] Enter [StartTime] Exit 2.Validate Data If data entry is incorrect Then [prompt user to renter data] Exit 3.Calculate Amount Paid If hours worked is < = 9 Then Amount paid =HoursWorked *N5 Else Amount Paid = HoursWorked * N10 Repeat Until there is no more Employee Exit 4.Print Amount Total Monthly Amount is |
What's The Easy Way To Learn Programming? / Top 10 Programming Languages To Learn / My Startup Failed in 28 months
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 45 |