Pascal newbie - Please help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Pascal newbie - Please help

annafannaf Posts: 5Member
Can someone tell me where I went wrong with this coding. Thanks.
Program EmployeePay (input, output);

Uses crt;

Const
PayRate=20.00;
Var
EmployeeName:string;
PayStatus:char;
Pay,HoursWorked:real;
Begin
Writeln('Enter Employee Name');
Readln(EmployeeName);
Writeln('Enter Pay Status');
Readln(PayStatus);

IF PayStatus='H' then
Begin
Writeln('Enter Hours Worked');
Readln(HoursWorked);
IF HoursWorked > 40 then
Pay:=(40 * PayRate) + (1.5 * (HoursWorked - 40) * PayRate)
ELSE
Pay:=HoursWorked * PayRate;
end
ELSE
IF PayStatus='S' then
Pay:=40 * PayRate;
Writeln('Employee Name', EmployeeName);
Writeln('Pay', Pay:3:2);
Readln
end.

Comments

  • zibadianzibadian Posts: 6,349Member
    : Can someone tell me where I went wrong with this coding. Thanks.
    [code]
    : Program EmployeePay [red](input, output)[/red];
    :
    : Uses crt;
    :
    : Const
    : PayRate=20.00;
    : Var
    : EmployeeName:string;
    : PayStatus:char;
    : Pay,HoursWorked:real;
    : Begin
    : Writeln('Enter Employee Name');
    : Readln(EmployeeName);
    : Writeln('Enter Pay Status');
    : Readln(PayStatus);
    :
    : IF PayStatus='H' then
    : Begin
    : Writeln('Enter Hours Worked');
    : Readln(HoursWorked);
    : IF HoursWorked > 40 then
    : Pay:=(40 * PayRate) + (1.5 * (HoursWorked - 40) * PayRate)
    : ELSE
    : Pay:=HoursWorked * PayRate;
    : end
    : ELSE
    : IF PayStatus='S' then
    : Pay:=40 * PayRate;
    : Writeln('Employee Name', EmployeeName);
    : Writeln('Pay', Pay:3:2);
    : Readln
    : end.
    [/code]
    :
    :
    The Pascal language doesn't have parameters after the word program.
    Otherwise it looks fine.
  • annafannaf Posts: 5Member
    Then why doesnt it work? When you enter the H or S it automatically calculates the pay to 0.00.

    Thanks for your input.

    : : Can someone tell me where I went wrong with this coding. Thanks.
    : [code]
    : : Program EmployeePay [red](input, output)[/red];
    : :
    : : Uses crt;
    : :
    : : Const
    : : PayRate=20.00;
    : : Var
    : : EmployeeName:string;
    : : PayStatus:char;
    : : Pay,HoursWorked:real;
    : : Begin
    : : Writeln('Enter Employee Name');
    : : Readln(EmployeeName);
    : : Writeln('Enter Pay Status');
    : : Readln(PayStatus);
    : :
    : : IF PayStatus='H' then
    : : Begin
    : : Writeln('Enter Hours Worked');
    : : Readln(HoursWorked);
    : : IF HoursWorked > 40 then
    : : Pay:=(40 * PayRate) + (1.5 * (HoursWorked - 40) * PayRate)
    : : ELSE
    : : Pay:=HoursWorked * PayRate;
    : : end
    : : ELSE
    : : IF PayStatus='S' then
    : : Pay:=40 * PayRate;
    : : Writeln('Employee Name', EmployeeName);
    : : Writeln('Pay', Pay:3:2);
    : : Readln
    : : end.
    : [/code]
    : :
    : :
    : The Pascal language doesn't have parameters after the word program.
    : Otherwise it looks fine.
    :

  • zibadianzibadian Posts: 6,349Member
    : Then why doesnt it work? When you enter the H or S it automatically calculates the pay to 0.00.
    :
    : Thanks for your input.
    :
    : : : Can someone tell me where I went wrong with this coding. Thanks.
    : : [code]
    : : : Program EmployeePay [red](input, output)[/red];
    : : :
    : : : Uses crt;
    : : :
    : : : Const
    : : : PayRate=20.00;
    : : : Var
    : : : EmployeeName:string;
    : : : PayStatus:char;
    : : : Pay,HoursWorked:real;
    : : : Begin
    : : : Writeln('Enter Employee Name');
    : : : Readln(EmployeeName);
    : : : Writeln('Enter Pay Status');
    : : : Readln(PayStatus);
    : : :
    : : : IF PayStatus='H' then
    : : : Begin
    : : : Writeln('Enter Hours Worked');
    : : : Readln(HoursWorked);
    : : : IF HoursWorked > 40 then
    : : : Pay:=(40 * PayRate) + (1.5 * (HoursWorked - 40) * PayRate)
    : : : ELSE
    : : : Pay:=HoursWorked * PayRate;
    : : : end
    : : : ELSE
    : : : IF PayStatus='S' then
    : : : Pay:=40 * PayRate;
    : : : Writeln('Employee Name', EmployeeName);
    : : : Writeln('Pay', Pay:3:2);
    : : : Readln
    : : : end.
    : : [/code]
    : : :
    : : :
    : : The Pascal language doesn't have parameters after the word program.
    : : Otherwise it looks fine.
    : :
    :
    :
    Did you type the H or S in uppercase, because the comparison is case-sensitive? Also you might get into trouble due to the fact that the Pay output could be truncated to 3 characters. Try to expand it to for example ':8:2'. It might also help.
  • annafannaf Posts: 5Member
    That was it. I wasnt using uppercase. Thanks for the help, your a doll.


    : Did you type the H or S in uppercase, because the comparison is case-sensitive? Also you might get into trouble due to the fact that the Pay output could be truncated to 3 characters. Try to expand it to for example ':8:2'. It might also help.
    :

Sign In or Register to comment.