Type mismatch

ManUtd222

New member
Type mismatch

מישהו יכול להגיד לי מה זאת השגיאה הזאת ואיך אפשר לפתור אותה? הנה הקוד: ==================================================================== program Targil6; var I, ProductCode,ProductPrice,NewPrice, X,Z: integer; begin for I := 1 to 10 do begin Writeln ('Enter product code:'); Readln (ProductCode); Writeln ('Enter Product Price:'); Readln (ProductPrice); X:= ProductCode / 7; {פה הוא עושה לי את השגיאה, הוא מצביע על ה-7.) if X mod 2 = 0 then begin Z:= (15 * ProductPrice)/ 100; NewPrice:= ProductPrice + Z; Writeln ('Product code is:', ProductCode); Writeln ('Product Price is:', ProductPrice); end; else if X mod 2 <> 0 then begin Z:= (10 * ProductPrice)/ 100; NewPrice:= ProductPrice - Z; Writeln ('Product code is:', ProductCode); Writeln ('Product Price is:', ProductPrice); end; end. ==================================================================== השגיאה היה בחילוק ב-7 , מישהו יכול להגיד לי איך אני פותר את זה? מצטער על הצפת השאלות בפסקל אבל זה פורום וכאן המקום לשאול, (לא..?)
 

ManUtd222

New member
שכחו מהשאלה האחרונה סידרתי

את זה כבר. תסכלו רגע. צריך לשנות מחירים של 10 מוצרים שונים. השינוי: מחלקים ב-7 את קוד המוצר, אם המנה של החילוק זוגית המחיר עולה ב-15% וא לא, הוא יורד ב-10%. להדפיס את קוד המוצר והמחיר החדש שלו. עכשיו כתבתי תוכנית אבל היא לא מסתדרת לי: =================================================================== program Targil6; var I, ProductCode, ProductPrice, NewPrice,X,Z: Real; begin for I:=1 to 10 do begin Writeln ('Enter product code:'); Readln (ProductCode); Writeln ('Enter Product price:'); Readln (ProductPrice); X:=(ProductCode) / 7; if X mod 2 = 0 then begin Z:= (15 * ProductPrice) / 100; NewPrice:= ProductPrice + Z; Writeln ('Product code is:', ProductCode); Writeln ('Product Price is:', ProductPrice); end; else if X mod 2 <> 0 then begin Z:= (10 * ProductPrice) / 100; NewPrice:= ProductPrice - Z; Writeln ('Product code is:', ProductCode); Writeln ('Product Price is:', ProductPrice); end; end; end. =================================================================== מה הבעיה בבקשה עזרה אני תקוע בשאלה הזאת תתקנו לי את הקוד בבקשה
 

ManUtd222

New member
כשהתכוונתי

תתקנו לי את הקוד, תמצאו לי את השגיאות ותנסו לעזור לי למצוא פתרונות לשגיאות. אין פה כוונה שתעשו לי את העבודה, את הקוד אני כתבתי לבד אבל הוא לא נותן לי להריץ - כלומר, יש שגיאות, תעזרו לי למצוא אותן בבקשה.
 

the another one

New member
X הוא INTEGER

כשאתה מחלק ב 7 אתה לא יכול להיות בטוח שהתוצאה תהיה שלמה. תשנה את הסוג של X ל REAL וזה יסתדר !
 

ManUtd222

New member
אם לא ראית

שיניתי את זה כבר(ראה הודעה 2 באשכול זה). זה הקוד העדכני. יש שם כמה שגיאות. תעזור לי למצוא אותם.
 

ManUtd222

New member
אוקיי הורדתי. שגיאה שאני מקבל:

Invalid for control variable הוא מצבע על שגיאה במשפט הזה for I:=1 to 10 do על ה-I. מה יכולה להיות השגיאה?
 

the another one

New member
שינית את כל המשתנים ל REAL

בלולאת FOR יכולים להיות רק משתנים מסוג CHAR או INTEGER
 

ManUtd222

New member
אז מה לעשות?

אני חייב for לתרגיל. אולי אני אשנה את זה ל-integer בחזרה אבל איך אני יעשה את החילוק? הסתבכתי.
 

ManUtd222

New member
הנה סידרתי את זה:

================================================================== program Targil6; var I, ProductCode, ProductPrice,X: integer; NewPrice,Z: Real; begin for I := 1 to 10 do begin Writeln ('Enter product code:'); Readln (ProductCode); Writeln ('Enter Product price:'); Readln (ProductPrice); X:= ProductCode div 7; if X mod 2 = 0 then begin Z:= (15 * ProductPrice) / 100; NewPrice:= ProductPrice + Z; Writeln ('Product code is:', ProductCode); Writeln ('Product Price is:', ProductPrice); end else if X mod 2 <> 0 then begin Z:= (10 * ProductPrice) / 100; NewPrice:= ProductPrice - Z; Writeln ('Product code is:', ProductCode); Writeln ('Product Price is:', ProductPrice); end; end; end. ================================================================== זה בסדר שעשיתי div? לפי נתוני השאלה אני מתכוון? זה מריץ לי את הקוד אבל משום מה נגיד אני מכניס 70 וקוד מספר 8888 אז מציג לי את זה בלי השינויים שצריכים להיעשות. כלומר, ההנחות...
 
למעלה