เด็กใหม่รบกวนหน่อยครับ

คือตอนนี้ผมเรียน ปวช.3  ภาควันอาทิตย์
อาจารย์ให้แก้โปรแกรมตัวนึงครับ เค้าบอกว่ามีที่ผิดอยู่ 2 จุด แต่ผมลองแก้หลายๆอย่างแล้วก็ยังไม่ได้
จึงใคร่ขอรบกวน ผู้รู้ช่วยแก้ให้หน่อยครับ จะสอบอาทิตย์หน้านี้แล้วครับ


โค๊ตที่เค้าให้มาครับ

PROGARM Case_Sample1;
USES      CRT;
VAR
    Salary,bonus : Real;
BEGIN
    CLRSCR;Write('Enter Your Salary =');ReadLn(salary);
      If Salary >0 Then
        Case BONUS Of
            2000 : Bonus := 2.5*Salary;
            1000 : Bonus := 2*Salary;
            5000 : Bonus := 1.5*Salary;
            3000 : Bonus := 1*Salary;
        Else
            Bonus := Salary;
        End
      Else
          Write('Your have not Salary');  clrscr;
      gotoxy(35,10);write('Your Bonus=' ,Bonus:10:2,' Bath ');
      writeln('PRESS ENTER TO CONTINUE0....');READLN
    END.


และเค้าบอกว่ามีผิดอยู่ 2 ที่คือ
1.Salary,bonus : Real;
2.Case BONUS Of

ผมลองใส่โค๊ตหลายๆตัวแล้วยังไงก็ยังไม่ได้
ผมขอรบกวนหน่อยครับ  ขอบคุณครับ
🏷️ หัวข้อที่เกี่ยวข้อง

💬 การตอบกลับ 1

#1
dekpascal
dekpascal
5 โพสต์
program    dekpascal;
uses      crt;
var        salary : integer;
          A,B,C,D,bonus : real;
BEGIN
      clrscr;
      write('Enter Your Salary  =  ');
      readln(salary);
      A := 2.5 * salary;
      B := 2 * salary;
      C := 1.5 * salary;
      D := 1 * salary;
      If salary > 0 Then
      begin
        Case salary of
            2000 : bonus := A;
            1000 : bonus := B;
            5000 : bonus := C;
            3000 : bonus := D;
      else
        bonus := salary;
      end;end;
      clrscr;
      writeln('Your Bonus  =',Bonus:8:2,' Bath');
      writeln('Press Enter To Continue....');
      readln;
end.