[Solved] Trade Fair with C++

Trade Fairs are important for companies to present their products and to get in touch with its customers and business parties. One such grandeur Trade Fair Event was organized by the Confederation of National Large Scale Industry.
Number of people who attended the event on the first day was x. But as days progressed, the event gained good response and the number of people who attended the event on the second day was twice the number of people who attended on the first day. Unfortunately due to heavy rains on the third day, the number of people who attended the event was exactly half the number of people who attended on the first day.

Given the total number of people who have attended the event in the first 3 days, find the number of people who have attended the event on day 1, day 2 and day 3.

Input Format:
First line of the input is an integer value that corresponds to the total number of people.

Output Format:
First line of the output should display the number of attendees on day 1.
Second line of the output should display the number of attendees on day 2.
Third line of the output should display the number of attendees on day 3.
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 total number of people
10500
Number of attendees on day 1 : 3000
Number of attendees on day 2 : 6000
Number of attendees on day 3 : 1500

Solution

#include <iostream>
using namespace std;

int main() {
    int total_attendees;
    cout << "Enter the total number of people" << endl;
    cin >> total_attendees;
    int first_day_attendees = (2 * total_attendees) / 7;
    int second_day_attendees = 2 * first_day_attendees;
    int third_day_attendees = first_day_attendees / 2;
    cout << "Number of attendees on day 1 : " << first_day_attendees << endl;
    cout << "Number of attendees on day 2 : " << second_day_attendees << endl;
    cout << "Number of attendees on day 3 : " << third_day_attendees << endl;
    return 0;
}
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		System.out.println("Enter the total number of people");

		int totalAttendees = scanner.nextInt();
		
		int firstDayAttendees = (2*totalAttendees)/7;
		
		int secondDayAttendees = 2*firstDayAttendees;
		
		int thirdDayAttendees = firstDayAttendees/2;
		
		System.out.println("Number of attendees on day 1 : " + firstDayAttendees);
		System.out.println("Number of attendees on day 2 : " + secondDayAttendees);
		System.out.println("Number of attendees on day 3 : " + thirdDayAttendees);
	}
}

Happy Learning – If you require any further information, feel free to contact me.

Share your love
Saurav Hathi

Saurav Hathi

I'm currently studying Bachelor of Computer Science at Lovely Professional University in Punjab.

📌 Nodejs and Android 😎
📌 Java

Articles: 444

Leave a Reply

Your email address will not be published. Required fields are marked *