IT4X เทคนิคคอมพิวเตอร์ โน๊ตบุค ข่าว IT
ข่าวสาร / ความรู้ => คนเขียนโปรแกรม => ข้อความที่เริ่มโดย: milk_sj ที่ กุมภาพันธ์ 05, 2010, 17:34:57
-
คืออาจารย์ที่โรงเรียนสอนไม่รู้เรื่องเลย หรือว่าหนูไม่รู้เรื่องเองก็ไม่รู้ เอาแต่สั่งๆๆๆอย่าเดียวเลย=.=
เดี๋ยวก็จะสอบอีกแล้ว ตอนนี้ถึง If ...Then อยู่อ่ะค่ะแล้ว คืออาจารย์สั่งให้ทำโปรแกรมคนละ 1 โปรแกรม
จะทำเป็นร้านขายอะไรก็ได้ แต่ต้องคำนวณด้วย ส่วนของหนูทำร้านขายvcd อ่ะค่ะคิดว่ามันไม่ได้ยุ่งยากมากนัก
ปัญหาคือคำนวณไม่ถูก ไม่ต้องทำให้ก็ได้นะคะ แค่อยากลองขอดูตัวอย่างว่า ต้องทำยังไงมาเป็นแนวคิดอะค่ะ
คือหนูอยากเรียนรู้และทำเองดูบ้างเพื่ออะไรจะได้ดีขึ้น รบกวนใครก็ได้นะคะนึกว่า สงสารเหอะ ตั้ง 30 คะแนนอ่ะคะ
ส่งก่อนปิดเทอมด้วย เวรรกรรมจริง :P ขอบคุณค่ะ
Program VCD;
Uses crt;
var Customer,Amount,NameType,Price,Total:string;
Begin
clrscr;
gotoxy(35,5);
Writeln('VCD Sapphire Blue');
gotoxy(15,8);
writeln('===========================================================');
gotoxy(15,10);
writeln(' Customer: Amount: NameType: Price: Total: ' );
gotoxy(15,12);
writeln('===========================================================');
gotoxy(15,14);
writeln(' A 2 Super Showl 1,500 3000 ');
gotoxy(15,16);
writeln(' B 4 Super Jr.05 300 12000 ');
gotoxy(15,18);
writeln(' C 1 Super Jr. M 500 500 ');
gotoxy(15,20);
writeln(' D 3 Super Showll 2,500 7500 ');
gotoxy(15,22);
writeln('------------------------------------------------------------');
gotoxy(15,24);
writeln('Circulation');
readln;
End.
ไปลองทำดูแล้วคะ แอต่คำนวณไม่ถูกช่วยดูหน่อยซิ
***ขอ บคุณ พี่ moshi มากๆๆคะ มันใช่เลยค่ะ แบบนี้ถูกต้องเลย !!!
แต่มีอีกเรื่องอะคะ หนูจะถามพี่ว่า ถ้าจะคำนวณผลรวมยอดขายTotalทั้งหมดเลย
ทำได้มั้ยอะคะ รบกวนอีกนิดได้ปะคะ ยอดขายทั้งหมดอะคะ ขอบคุณอีกครั้งนะคะ
งานหนูส่งพรุ่งนี้แล้วคะ ได้เต็มแน่ เลย คิคิ
-
รอผู้รู้ละกันนะ :P
-
ก็ไม่น่าจะมีอะไรยากนะครับ
ร้านขาย Vcd เหรอ ก็อืม....
รับว่าจะซ์้อกี่แผ่น แผ่นนี้ราคาเท่าไหร่
คราวนี้เราก็มาเพิ่ม If then ให้ โดยมีเงื่อนไขประมาณว่า
ถ้าซื้อเกิน 100 ลดให้ 1%
ซื้อเกิน 200 ลด 2%
อะไรก็ว่าไปครับ~ ลองทำดูนะ
-
Program VCD;
Uses crt;
var amount,price,total:integer;
Begin
clrscr;
Writeln('VCD Sapphire Blue - Promotion Buy Up 1000 Down 100 Bath');
writeln('===========================================================');
writeln(' Customer: Amount: NameType: Price: Total: ' );
writeln('===========================================================');
amount:=2;price:=1500;total:=amount*price;
if total>=1000 then total:=(total-100);
writeln(' A ',amount,' Super Showl ',price,' ',total,' ');
amount:=4;price:=300;total:=amount*price;
if total>=1000 then total:=(total-100);
writeln(' B ',amount,' Super Jr.05 ',price,' ',total,' ');
amount:=1;price:=500;total:=amount*price;
if total>=1000 then total:=(total-100);
writeln(' C ',amount,' Super Jr. M ',price,' ',total,' ');
amount:=3;price:=2500;total:=amount*price;
if total>=1000 then total:=(total-100);
writeln(' D ',amount,' Super Showll ',price,' ',total,' ');
writeln('------------------------------------------------------------');
writeln('End Program');
readln;
End.
ไปดัดแปลงต่อเอาเองนะ ช่วยแค่นี้แหละ
-
เพิ่ม Sum หรือผลรวมนั้นเอง
Program VCD;
Uses crt;
var amount,price,total,sum:integer;
Begin
clrscr;
Writeln('VCD Sapphire Blue - Promotion Buy Up 1000 Down 100 Bath');
writeln('===========================================================');
writeln(' Customer: Amount: NameType: Price: Total: ' );
writeln('===========================================================');
amount:=2;price:=1500;total:=amount*price;
if total>=1000 then total:=(total-100);
writeln(' A ',amount,' Super Showl ',price,' ',total,' ');sum:=sum+total;
amount:=4;price:=300;total:=amount*price;
if total>=1000 then total:=(total-100);
writeln(' B ',amount,' Super Jr.05 ',price,' ',total,' ');sum:=sum+total;
amount:=1;price:=500;total:=amount*price;
if total>=1000 then total:=(total-100);
writeln(' C ',amount,' Super Jr. M ',price,' ',total,' ');sum:=sum+total;
amount:=3;price:=2500;total:=amount*price;
if total>=1000 then total:=(total-100);
writeln(' D ',amount,' Super Showll ',price,' ',total,' ');sum:=sum+total;
writeln('------------------------------------------------------------');
writeln('Total = ',sum);
writeln('End Program');
readln;
End.