เงื่อนไข ห้องทั้ง 7 ประเภทห้องพัก สามารเลือกได้ไม่เกิน 3 หากเลือกเกิน 3 ให้โปรแกรมหยุดทำงานทั้นที

ขี้แงขี้แงขี้แงขี้แงห้องพักมี 7 ประเภท โปรแกรมจะรันครบทั้ง 7 ประเภทห้องแล้วจะคำนวณราคาของห้องออกมา
จะตั่งเงื่อนไข ทั้ง 7 ประเภทห้องพัก ถ้า  n  เท่ากับ 1 ให็โปรแกรมทำงานต่อไป
                                               ถ้า n ไม่เท่ากับ 1 ให้โปรแกรมหยุดทำงานทั้นที
แล้วทำคำสั่งออกจากโปรแกรม ใครทำได้ช่วยบอกหน่อยนะ ขี้แง
#include<stdio.h>
#include<conio.h>
void main(void)
{
    clrscr();

    int superior;
    int deluxe;
    int studio;
    int junior;
    int duplex;
    int twobedroom;
    int famil;
    int sum1;
    int sum2;
    int sum3;
    int sum4;
    int sum5;
    int sum6;
    int sum7;
    int p1=500;
    int p2=600;
    int p3=700;
    int p4=800;
    int p5=900;
    int p6=1000;
    int p7=1500;
    int b;
    int s;
    int j;
    int sc;
    int se;
    int ea;
    int nf;
    int br=150;
    int sw=100;
    int ja=100;
    int sd=130;
    int sf=599;
    int ef=399;
    int no=499;
    int sum8;
    int total;
    int rates1;
    int rates2;
    int rates3;
    int rates4;
    int rates5;
    int rates6;
    int rates7;
    int mony;
    int change;
    char Ans;
do
{
    clrscr();
    textcolor(4);
    gotoxy(25,2);cprintf("   +++ Welcome Jaravee Hotel +++   ");
    gotoxy(23,3);cprintf("อออออออออออออออออออออออออออออออออออ");
    textcolor(3);
    gotoxy(1,5);cprintf  ("         ROOM TYPE           ");
    gotoxy(1,6);cprintf  ("..............................");
    gotoxy(2,7);cprintf  ("SUPERIOR             ณ 500.-");
    gotoxy(2,8);cprintf  ("DELUXE               ณ 600.-");
    gotoxy(2,9);cprintf  ("STUDIO               ณ 700.-");
    gotoxy(2,10);cprintf ("JUNIOR SUITE         ณ 800.-");
    gotoxy(2,11);cprintf ("DUPLEX SUITE         ณ 900.-");
    gotoxy(2,12);cprintf ("TOW BED ROOM SULTE   ณ 1000.-");
    gotoxy(2,13);cprintf ("FAMILY SUITES        ณ 1500.-");
    gotoxy(1,14);cprintf ("..............................");

    gotoxy(1,16);cprintf ("    ADDITIONAL SERVICES      ");
    gotoxy(1,17);cprintf (".............................");
    gotoxy(4,18);cprintf  ("BREEZE          ณ 150.-");
    gotoxy(4,19);cprintf  ("SWIMMING POOL   ณ 100.-");
    gotoxy(4,20);cprintf  ("JACOZZI         ณ 100.-");
    gotoxy(4,21);cprintf  ("SCUDA DIVING    ณ 130.-");
    gotoxy(4,22);cprintf  ("SEA FOOD        ณ 599.-");
    gotoxy(4,23);cprintf  ("EAST FOOD       ณ 499.-");
    gotoxy(4,24);cprintf  ("NORTHERN'S FOOD ณ 399.-");
    gotoxy(1,25);cprintf  ("............................");



    gotoxy(40,5); cprintf("Select Room Typr.?");
    textcolor(1);
    gotoxy(40,7); cprintf("1.Superior");
    gotoxy(60,7); scanf("%d",&superior);
    gotoxy(60,7); cprintf("%d\n",sum1=superior*p1);
    gotoxy(40,7); cprintf("2.Deluxe");
    gotoxy(60,7); scanf("%d",&deluxe);
    gotoxy(60,7); cprintf("%d\n",sum2=deluxe*p2);
    gotoxy(40,7); cprintf("3.Studio");
    gotoxy(60,7); scanf("%d",&studio);
    gotoxy(60,7); cprintf("%d\n",sum3=studio*p3);
    gotoxy(40,7); cprintf("4.Junior Suite");
    gotoxy(60,7); scanf("%d",&junior);
    gotoxy(60,7); cprintf("%d\n",sum4=junior*p4);
    gotoxy(40,7); cprintf("5.Duplex Suite");
    gotoxy(60,7); scanf("%d",&duplex);
    gotoxy(60,7); cprintf("%d\n",sum5=duplex*p5);
    gotoxy(40,7); cprintf("6.Two Bedroom Sulte");
    gotoxy(60,7); scanf("%d",&twobedroom);
    gotoxy(60,7); cprintf("%d\n",sum6=twobedroom*p6);
    gotoxy(40,7); cprintf("7.Family Suites");
    gotoxy(60,7); scanf("%d",&famil);
    gotoxy(60,7); cprintf("%d\n",sum7=famil*p7);
    textcolor(4);
    gotoxy(40,8); cprintf("All room rates selected =");
    gotoxy(65,8);cprintf("%d\n",sum8 =sum1+sum2+sum3+sum4+sum5+sum6+sum7);

    textcolor(13);
    gotoxy(38,9);cprintf("ออออออออออออออออออออออออออออออออออ");
    gotoxy(40,10);cprintf("Service charge ? ");
    gotoxy(40,11);cprintf("Breeze Spa");
    gotoxy(60,11);scanf("%d",&b);
    gotoxy(60,11);cprintf("= %d",rates1=b*br);
    gotoxy(40,12);cprintf("Swimming pool");
    gotoxy(60,12);scanf("%d",&s);
    gotoxy(60,12);cprintf("= %d",rates2=s*sw);
    gotoxy(40,13);cprintf("Jacozzi");
    gotoxy(60,13);scanf("%d",&j);
    gotoxy(60,13);cprintf("= %d",rates3=j*ja);
    gotoxy(40,14);cprintf("Scuda Diving");
    gotoxy(60,14);scanf("%d",&sc);
    gotoxy(60,14);cprintf("= %d",rates4=sc*sd);
    gotoxy(40,15);cprintf("Sea Food");
    gotoxy(60,15);scanf("%d",&se);
    gotoxy(60,15);cprintf("= %d",rates5=se*sd);
    gotoxy(40,16);cprintf("East Food");
    gotoxy(60,16);scanf("%d",&ea);
    gotoxy(60,16);cprintf("= %d",rates6=ea*ef);
    gotoxy(40,17);cprintf("Northern's Food");
    gotoxy(60,17);scanf("%d",&nf);
    gotoxy(60,17);cprintf("= %d",rates7=nf*no);
    gotoxy(40,18);cprintf("อออออออออออออออออออออออออออ");

    textcolor(12);


    textcolor(4);
    textcolor(12);
    gotoxy(45,20);cprintf("Total = %d",total=sum8+rates1+rates2+rates3+rates4+rates5+rates6+rates7);

    textcolor(14);
    gotoxy(45,21);cprintf("Money = ");
    gotoxy(53,21);scanf("%d",&mony);
    gotoxy(53,21);cprintf("%d",mony);

    textcolor(7);
    gotoxy(51,22);cprintf("= %d",change=mony-total);
    textcolor(4);
    gotoxy(53,23);cprintf("ออออออ");
    gotoxy(47,24);cprintf("              EXIT      ");
    textcolor(15);
    Ans=getch();
}while(Ans =='3'|| Ans =='3');
}
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่