Need Help With assingment

defcomk

Senior Member
Joined
Oct 16, 2007
Messages
774
ok well iv done the assignment but i cant get the program to run properly heres the code for pascal and pseudo code i just need to know what i am doing wrong.
What it states in the instruction
A Company allocates golfing hours to its directors at the end of each month.
Write a program into which the current numbers of directors is then passed to a function which requests the names and the total number of golfing hours accumulated at the start of the current month for each director. During the month, the number of hours worked during the day by each director is added to a list. Assume that no two directors work the same number of hours in a month. These list are used as inputs to the function to determine the total number of hours worked per director during the month (hours = 0 indicates the end of each directors list ). Directors are given one hours golfing for every eight hours work that they submit.

The Function prints a report for each director showing the directors name, golfing hours accumulated at the start of the month ,and the total number of golfing hours earned during the month and the total number of golfing phones accumulated at the end of the month.

A summary at the end of the report shows the name and number of golfing hours of the director who has accumulated the most hours.

The Total number of directors who have morethan 50 hours golfing time is returned to the main program which prints the number.

BEGIN
Ghours = 0
TOTALWH = 0

do While Whours = 0
INPUT NAME
INPUT HOURS WORKED
INPUT ADDITIONAL GOLFING HOURS

Ghours = Hours Worked / 8
TotGhours = Ghours + ADDITIONAL GOLFING HOURS
//summary
PRINT NAME
PRINT Ghours
PRINT ADDITIONAL GOLFING HOURS
PRINT TOTAL GOLFING HOURS
//DIR HIGH EANERS
PRINT NAME
PRINT HOURS
IF Ghours >50 THEN
PRINT Ghours >50
END

program HOURS;
uses crt;
var Name: string;
var GHours, TotGHours, AddGHours, Whours, totalWH: integer;
begin
CLRSCR;
Ghours := 0; totalWH :=0;
//REPEAT CODE
repeat
WRITELN('Enter Name ');
READLN(Name);
WRITELN('Enter Hours Worked ');
READLN(Whours);
WRITELN('Enter any Additional hours ');
READLN(AddGHours);
Ghours := Whours DIV 8;
TotGHours := Ghours + AddGHours ;
totalWH := Whours + 1 ;
until Whours = 0;
//SUMMARY
WRITELN('Name: ',Name );
WRITELN('Golfing Hours Earned: ',Ghours);
WRITELN('Additional Golfing Hours: ', AddGHours);
//HIGHEST EARNING MEMBERS
WRITELN('Total Golfing Hours: ',TotGHours);
WRITELN('Highest Earners',Name,':',GHours);
//DIR WITH MORETHAN 50 HOURS OF PLAY TIME
if TotGHours >50
then WRITELN('Total Hours', TotGHours >50);


While not keypressed do

end.
 

vatteva

Active Member
Joined
Dec 14, 2009
Messages
76
this seems very similar to turbo delphi but nonetheless im sorry bud i just dont get this, and to attempt to figure this out would take way to long.

Ask your teacher/lecturer to take a look :)
 

Drake2007

Expert Member
Joined
Oct 23, 2008
Messages
4,413
No idea either with that language but you may want to rather use an array to hold the directors data. Go through the requirement and highlight all the nouns in it to see what variables your array needs to hold for each director.

Write a program into which the current numbers of directors is then passed to a function <- I see repeat until in your code, that doesn't seem like a function to me.
 

zjvren

Member
Joined
Nov 17, 2008
Messages
28
Not sure if Pascal is case sensitive, but I'm seeing some case issues in your code. See below:
You declare as follows: var GHours
But then you use as follows: Ghours := Whours DIV 8; Ghours := 0;

Fix that and see if it runs :)
 
Top