E
ehabaziz2001
Please switch in that program not working .
#include <stdio.h>
/*TV Rental Bills -Version15-using structures*/
void customer_input(struct customer_record *);
void print_bill(struct customer_record *,int);
struct customer_record
{
int customer_no;
int no_of_weeks;
char tv_type;
float tv_type_value;
float tv_bill;
};
main ()
{
struct customer_record customer;
float rent_per_week;
float week_rental;
char another_bill;
int i=0;
do {
i++;
//system("cls");
printf("\n Csutomer data No %d :",i);
printf("\n ========================");
customer_input(&customer);
print_bill(&customer,i);
printf("\nIs there a bill to be processed (y or n)");
scanf("\n");
scanf("%c",&another_bill);
} while (another_bill=='y');
return 0;
}
void customer_input(struct customer_record *cust)
/*----------------------------------------------*/
{
printf("\nEnter customer number :");
scanf("%4d",&(*cust).customer_no);
printf("\nEnter number of weeks rent due :");
scanf("%2d",&(*cust).no_of_weeks);
printf("Enter type of rental -c (3.60) for colors TV");
printf("\n -b (1.75) for black and white TV");
printf("\n -v (1.50) for video");
printf("\n -o (Not handle) for other : ");
scanf("\n");
scanf("%c",&(*cust).tv_type);
switch ((*cust).tv_type)
{
case 'c':
(*cust).tv_type_value=3.60;
case 'b':
(*cust).tv_type_value=1.75;
case 'v':
(*cust).tv_type_value=1.50;
default :
printf("\n Program does not handle this type of rental\n");
}
printf("\n Number of weeks rent due : %-2d",
(*cust).no_of_weeks);
printf("\n Type of rental : %-c ",(*cust).tv_type);
printf("\n Value for that type : %.2f\n",
(*cust).tv_type_value);
(*cust).tv_bill=((*cust).no_of_weeks)*((*cust).tv_type_value);
}
void print_bill(struct customer_record *cust,int k)
/*------------------------------------------------*/
{
printf("\n BILL No for Customer %d :",k);
printf("\n ========================");
printf("\n Customer number : %-4d",
(*cust).customer_no);
printf("\n Number of weeks rent due : %-2d",
(*cust).no_of_weeks);
printf("\n Type of rental : %-c ",(*cust).tv_type);
printf("\n Value for that type : %.2f\n",
(*cust).tv_type_value);
printf("\n Value of bill : %.2f\n",
(*cust).tv_bill);
}
#include <stdio.h>
/*TV Rental Bills -Version15-using structures*/
void customer_input(struct customer_record *);
void print_bill(struct customer_record *,int);
struct customer_record
{
int customer_no;
int no_of_weeks;
char tv_type;
float tv_type_value;
float tv_bill;
};
main ()
{
struct customer_record customer;
float rent_per_week;
float week_rental;
char another_bill;
int i=0;
do {
i++;
//system("cls");
printf("\n Csutomer data No %d :",i);
printf("\n ========================");
customer_input(&customer);
print_bill(&customer,i);
printf("\nIs there a bill to be processed (y or n)");
scanf("\n");
scanf("%c",&another_bill);
} while (another_bill=='y');
return 0;
}
void customer_input(struct customer_record *cust)
/*----------------------------------------------*/
{
printf("\nEnter customer number :");
scanf("%4d",&(*cust).customer_no);
printf("\nEnter number of weeks rent due :");
scanf("%2d",&(*cust).no_of_weeks);
printf("Enter type of rental -c (3.60) for colors TV");
printf("\n -b (1.75) for black and white TV");
printf("\n -v (1.50) for video");
printf("\n -o (Not handle) for other : ");
scanf("\n");
scanf("%c",&(*cust).tv_type);
switch ((*cust).tv_type)
{
case 'c':
(*cust).tv_type_value=3.60;
case 'b':
(*cust).tv_type_value=1.75;
case 'v':
(*cust).tv_type_value=1.50;
default :
printf("\n Program does not handle this type of rental\n");
}
printf("\n Number of weeks rent due : %-2d",
(*cust).no_of_weeks);
printf("\n Type of rental : %-c ",(*cust).tv_type);
printf("\n Value for that type : %.2f\n",
(*cust).tv_type_value);
(*cust).tv_bill=((*cust).no_of_weeks)*((*cust).tv_type_value);
}
void print_bill(struct customer_record *cust,int k)
/*------------------------------------------------*/
{
printf("\n BILL No for Customer %d :",k);
printf("\n ========================");
printf("\n Customer number : %-4d",
(*cust).customer_no);
printf("\n Number of weeks rent due : %-2d",
(*cust).no_of_weeks);
printf("\n Type of rental : %-c ",(*cust).tv_type);
printf("\n Value for that type : %.2f\n",
(*cust).tv_type_value);
printf("\n Value of bill : %.2f\n",
(*cust).tv_bill);
}