How to auto assign the room number and print the room number for those who booked the room successfully?
How to check room availability?
How to get the data/values from the struct?
I stuck here, don't know how to continue. Can anyone please help? Here is my code.
#include <stdio.h>
int i=0,option,room,week; int A1_I,A1_L,A1_M,A1_G; int A1_I_rate,A1_L_rate; int A1_rate=400, A1_I_rate=4-0,A1_L_rate=20; int total_room, total_I,total_L, I_week, L_week,grand_total;
struct booking{ char name[100]; int SID[100]; char sex; int room; }b[3];
void Main_Menu(){ //variable here : option printf("\n1 Room Booking\n2 Room Availability\n3 Cancel Booking\n4 Payment Details\nPlease enter your option:"); scanf("%i",&option);}
void book(){ printf("\n============== Room Booking ===============\n"); printf("\nEnter your details please.\nName:"); scanf("%s",b[1].name); printf("\nStudent ID:"); scanf("%i",b[i].SID); //variable here : sex printf("\nM for male, F for female\nGender:"); scanf("%s",&b[1].sex); //variable here : room printf("\n1 Single room\n2 Double bedded room\n3 Three bedded room\n4 Four bedded room\nPlease enter your option:"); scanf("%i",&b[1].room); printf("\nHow many weeks to book for?\n"); scanf("%i",&week); printf("\n==========================================\n");}
void bill(){ total_room=A1_rateweek; total_L = A1_L_rateL_week; total_I = A1_I_rate*I_week; grand_total=total_room+total_L+total_I; printf("\n==========================================\n"); printf("\nThank you for booking with us. Here is your bill."); printf("\n\nWeekly rate for the room\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the laundry\t: RM20\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the Internet: RM%i\n%i weeks of subscription\t\t: RM%i\nTotal amount payable is RM%i.\n",A1_rate,week,total_room,L_week,total_L,A1_I_rate,I_week,total_I,grand_total); printf("\n==========================================\n");}
int main(){ printf("\n========== Welcome to Wisdom College Hostel Management System ===========\n"); Main_Menu(); switch(option){ case 1: for(i=0;i<3;i++){ book();
Internet:
printf("\nDo you want to subscribe for Internet?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A1_I);
if(A1_I==1){
A1_I_rate=40;
printf("How many weeks to subscribe for?\n");
scanf("%i",&I_week);
goto Laundry;}
if(A1_I==2){
A1_I_rate=0;
goto Laundry;}
else{
goto Internet;}
Laundry:
printf("\nDo you want to subscribe for Laundry?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A1_L);
if(A1_L==1){
printf("How many weeks to subscribe for?\n");
scanf("%i",&L_week);
goto Meal;}
if(A1_L==2){
A1_L_rate=0;
goto Meal;}
else{
goto Laundry;}
Meal:
printf("\nDo you want to subscribe for Meal?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A1_M);
if(A1_M==1){
printf("\nSorry. This service is not available for subscription.\n");
goto Gym;}
if(A1_M==2){
goto Gym;}
else{
goto Meal;}
Gym:
printf("\nDo you want to subscribe for Gym?\n1 Yes\n2 No\nPlease enter your option:");
scanf("%i",&A1_G);
if(A1_G==1){
printf("\nSorry. This service is not available for subscription.\n");
bill();
break;}
if(A1_G==2){
bill();}
else{
goto Gym;}
bill();
printf("\n============== Room Details ===============\n");
printf("Name:%c\nStudent ID:%i\nGender:%s\nBlock:\nRoom Number:%i\n");
break;}}}
How to get the data/values from the struct?
I stuck here, don't know how to continue. Can anyone please help? Here is my code.
#include <stdio.h>
int i=0,option,room,week;
int A1_I,A1_L,A1_M,A1_G;
int A1_I_rate,A1_L_rate;
int A1_rate=400, A1_I_rate=4-0,A1_L_rate=20;
int total_room, total_I,total_L, I_week, L_week,grand_total;
struct booking{
char name[100];
int SID[100];
char sex;
int room;
}b[3];
void Main_Menu(){
//variable here : option
printf("\n1 Room Booking\n2 Room Availability\n3 Cancel Booking\n4 Payment Details\nPlease enter your option:");
scanf("%i",&option);}
void book(){
printf("\n============== Room Booking ===============\n");
printf("\nEnter your details please.\nName:");
scanf("%s",b[1].name);
printf("\nStudent ID:");
scanf("%i",b[i].SID);
//variable here : sex
printf("\nM for male, F for female\nGender:");
scanf("%s",&b[1].sex);
//variable here : room
printf("\n1 Single room\n2 Double bedded room\n3 Three bedded room\n4 Four bedded room\nPlease enter your option:");
scanf("%i",&b[1].room);
printf("\nHow many weeks to book for?\n");
scanf("%i",&week);
printf("\n==========================================\n");}
//printf("\n==========================================\n");}
void bill(){
total_room=A1_rateweek;
total_L = A1_L_rateL_week;
total_I = A1_I_rate*I_week;
grand_total=total_room+total_L+total_I;
printf("\n==========================================\n");
printf("\nThank you for booking with us. Here is your bill.");
printf("\n\nWeekly rate for the room\t: RM%i\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the laundry\t: RM20\n%i weeks of subscription\t\t: RM%i\nWeekly rate for the Internet: RM%i\n%i weeks of subscription\t\t: RM%i\nTotal amount payable is RM%i.\n",A1_rate,week,total_room,L_week,total_L,A1_I_rate,I_week,total_I,grand_total);
printf("\n==========================================\n");}
int main(){
printf("\n========== Welcome to Wisdom College Hostel Management System ===========\n");
Main_Menu();
switch(option){
case 1:
for(i=0;i<3;i++){
book();
@ash15khng and be sure to provide us with the resulting URL for the repl! haha