Wednesday, 25 July 2018

Question: Ticket sold for Charity Event
 
HelpIndia, a famous NGO has been selective in identifying events to raise funds for charity. Suzanne is a volunteer from the NGO who was selling tickets to the public for the charity event. She sold 'X' more adult tickets than children tickets and she sold twice as many senior tickets as children tickets. Assume that an adult ticket costs $5, children ticket costs $2 and senior ticket costs $3.
Suzanne made 'Y' dollars from ticket sales. Find the number of adult tickets, children tickets and senior tickets.

Input Format:
First input is an integer value X that corresponds to the number of adult tickets more than children tickets.
Second input is an integer value Y that corresponds to the money in dollars made by Suzanne from ticket sales.

Output Format:
First line of the output should display the number of children tickets sold.
Second line of the output should display the number of adult tickets sold.
Third line of the output should display the number of senior tickets sold.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]

Sample Input and Output :
Enter the value of X
10
Enter the value of Y
700
Number of children tickets sold : 50
Number of adult tickets sold : 60
Number of senior tickets sold : 100


SOLUTION:
 #include<stdio.h>
int main()
{
    int x,y;
    int b,a,s;
    printf("Enter the value of X");
    scanf("%d",&x);
    printf("\nEnter the value of Y");
    scanf("%d",&y);
    b=(y-(5*x))/13;
    a=x+b;
    s=2*b;
    printf("\nNumber of children tickets sold : %d",b);
    printf("\nNumber of adult tickets sold : %d",a);
    printf("\nNumber of senior tickets sold : %d",s);
    return 0;
}

3 comments:

  1. cost of chilren(c) tickets is 2 ,adult(a) is 5,senior(s) is 3.here a=2+c,s=2c,and multiply c with 2 ,a with 5 and s with 2.(since we are equating with the total ticket cost(Y)) hence the mathematical equation becomes 2c+5(X+c)+3(2c).from this we get c={Y-5X}/13

    ReplyDelete
    Replies
    1. Bro still can't understand. Can you explain very detailly please

      Delete

Random password generator in Java

       Random password generator in Java Source code: mport java.io.*; import java.util.*; public class Main { public static void main(Str...