Jane has opened a new fitness center with charges of 2500 per month so the cost to become a member of a fitness center is as follows: (a) For senior citizens discount is 30%; (b) For young one, the discount is 15%; and int roll_no; string name; int phone_number; }; int main(){ student p1 = {1,"Brown",123443}; student p2; p2 = p1; cout << "roll no : " << p2.roll_no << endl; cout << "name : " << p2.name << endl; cout << "phone number : " << p2.phone_number << endl; return 0; } 5. Lab Exercise: Lab Task 1: Jane has opened a new fitness center with charges of 2500 per month so the cost to become a member of a fitness center is as follows: (a) For senior citizens discount is 30%; (b) For young one, the discount is 15%; and (c) For adults, the discount is 20%. Write a menu-driven program (using structure) that a. Add new member b. Displays the general information about the fitness center and its charges. c.
#include<stdio.h>
#include<stdlib.h>
struct details
{
char name[30];
int eid;
int age;
}mem[5];
int Name;
int Age;
void mem_search(int r)
{
int id,i;
printf("\nEnter Member-Id to be Searched : ");
scanf("%d",&id);
printf("----------------------------------------\n");
for(i=0;i<r;i++)
{
if(mem[i].eid==id)
{
printf("Member Id : %d",mem[i].eid);
printf("\nName : %s",mem[i].name);
printf("\nAge : %d\n",mem[i].age);
}
}
}
void display(int r)
{
int i;
printf("\nMembers will be alloted discount on the basis of their age : 15%% for Young ; 20%% for Adult ; 30% for Old/Elderly \n")
printf("\nList of All Members:\n");
printf("-------------------------------\n");
printf("Mem-Id\tMem-Name Age\n");
printf("--------------------------------\n");
for(i=0;i<r;i++)
{
printf("%d\t%s\t %d\n",mem[i].eid,mem[i].name,mem[i].age);
}
}
void money(int r)
{
int charge_per_month,senior_citizen_discount,young_discount,adult_discount,age,total_money;
string name;
charge_per_month = 2500;
printf("Enter your name: ");
scanf("%s", & Name);
printf("Enter your age: ");
scanf("%d", & Age);
if (age < 18)
{
printf("For young the discount is 15%");
total_money = charge_per_month - (charge_per_month * 0.15);
printf("Total money: \n", total_money);
}
if (age > 18)
{
printf("For adult the discount is 20%");
total_money = charge_per_month - (charge_per_month * 0.20);
printf("Total money: ", total_money);
}
if (age > 60)
{
printf("For adult the discount is 30% \n");
total_money = charge_per_month - (charge_per_month * 0.30);
printf("Total money: \n", total_money);
}
}
int main()
{
int n,i,ch;
printf("/*How Many Members you want to add*/\n\nEnter Limit : ");
scanf("\n %d",&n);
for(i=0;i<n;i++)
{
printf("-----------------------------------------");
printf("\n\tEnter Details of Member-%d",i+1);
printf("\n-----------------------------------------");
printf("\nName of Member : ");
scanf("%s",mem[i].name);
printf("Member-Id : ");
scanf("%d",&mem[i].eid);
printf("Age : ");
scanf("%d",&mem[i].age);
}
while(1)
{
printf("-----------------------------------------\n");
printf("\t\tMenu\n");
printf("-----------------------------------------");
printf("\n 1:Search Member by E-ID");
printf("\n 2:List of All Members");
printf("\n 3:Total Money Made ");
printf("\n 4:Exit");
printf("\n----------------------------------------\n");
printf("Enter Your Choice : ");
scanf("\n %d",&ch);
switch(ch)
{
case 1: mem_search(n);
break;
case 2: display(n);
break;
case 3: money(n);
break;
case 4: exit(0);
}
}
return 0;
}
Comments
Leave a comment