5. [40 points] Write a C program with a subroutine that called MoviePassMember t
ID: 3753147 • Letter: 5
Question
5. [40 points] Write a C program with a subroutine that called MoviePassMember that checks if the person is a member or not. If he/she is a member, the price is $4 for all ages. If the person is not a member, then he/she must pay variable price based on age. Write another subroutine called MoviePrice that calculates the movie ticket price based on the input argument called age. If the age is 12 or under, the price is $6. If the age is between 13 and 64, the price is $8. If the age is 65 or above price is $7. Implement MoviePassMember subroutine in Assembly MoviePrice subroutine in CExplanation / Answer
Find the Below C - Program on how to find the ticket price for a person with particular age group, using subroutines MoviePrice and MoviePassMember.
#include <stdio.h>
int MoviePrice(int age);
int MoviePassMember();
int main(void) {
// your code goes here
int age = 12;
int ticketPrice = MoviePrice(age);
printf("%d",ticketPrice);
return 0;
}
//Subroutine to return whether the person is Member or not
int MoviePassMember(){
// Since no info is given on how to get know how whether the is person is member or not, Assuming not member
// By making isMember to 1 it will consider it as Member
int isMember = 0;
if(isMember){
return 1;
}
else{
return 0;
}
}
//Subroutine to calculate the price of the ticket depending on age.
int MoviePrice(int age){
int isPassMember;
isPassMember = MoviePassMember();
if(isPassMember){
return 4;
}
else {
if(age <= 12){
return 6;
}
else if(age>12 && age<=64 ){
return 8;
}
else{
return 7;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.