"how" is to generic, focus on steps you have to take in order to solve it
#include<stdio.h>
#include <stdlib.h>
int main()
{
float fullBord[3] = {25555,17500,9000};
float halfBord[3] = {1500,12500,7250};
float cardDiscounts[3] = {12.5,11.5,9.5};
int roomType;
char packge;
int days;
char cardType;
float price;
int selectedRoom;
float discount;
float total;
float discountedTotal;
//infinite loop
for(;;)
{
printf("\nEnter room type :");
scanf(" %d",&roomType);
// if user print -1 stop the proccess
// since array starts with 0 map user entered value with array index
if(roomType == 1)
{
selectedRoom = 0;
}
else if(roomType == 2)
{
selectedRoom = 1;
}
else if(roomType == 3)
{
selectedRoom = 2;
}
else
{
printf("Invalid Input");
break;
}
printf("Enter accommodation type (F/H) : ");
scanf(" %s",&packge);
printf("Enter number of days : ");
scanf(" %d",&days);
printf("Enter card type (G/S/B) : ");
scanf(" %s",&cardType);
//get price based on the user entered accommodation details
if(packge =='F')
{
price = fullBord[selectedRoom];
}
else
{
price = halfBord[selectedRoom];
}
//select discount based card type
if(cardType == 'G')
{
discount = cardDiscounts[0];
}
else if(cardType == 'S')
{
discount = cardDiscounts[1];
}
else if(cardType == 'B')
{
discount = cardDiscounts[2];
}
else
{
discount = 0;
}
//calculate total
total = price * days;
//calculate disconut total
discountedTotal = total - (total * discount /100);
printf("\nDiscount : %.2f ",discount);
printf("\nAmount(RS): %.2f ",discountedTotal);
}
}