Total Expenses for the Event: The prime functionality of an Event Management System is budgeting. An Event Management System should estimate the total expenses incurred by an event and the percentage rate of each of the expenses involved in planning and executing an event. Nikhil, the founder of “Pine Tree” wanted to include this functionality in his company’s Amphi Event Management System and requested your help in writing a program for the same.
The program should get the branding expenses, travel expenses, food expenses and logistics expenses as input from the user and calculate the total expenses for an event and the percentage rate of each of these expenses.
Input Format:
First input is a int value that corresponds to the branding expenses.
Second input is a int value that corresponds to the travel expenses.
Third input is a int value that corresponds to the food expenses.
Fourth input is a int value that corresponds to the logistics expenses.
Output Format:
First line of the output should display the int value that corresponds to the total expenses for the Event.
Next four lines should display the percentage rate of each of the expenses.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]
Sample Input and Output 2 :
Enter branding expenses
20000
Enter travel expenses
40000
Enter food expenses
15000
Enter logistics expenses
25000
Total expenses : Rs.100000.00
Branding expenses percentage : 20.00%
Travel expenses percentage : 40.00%
Food expenses percentage : 15.00%
Logistics expenses percentage : 25.00%
Sample Input and Output 2 :
Enter branding expenses 855 Enter travel expenses 877779 Enter food expenses 5544 Enter logistics expenses 2256 Total expenses : Rs.886434.00 Branding expenses percentage : 0.10% Travel expenses percentage : 99.02% Food expenses percentage : 0.63% Logistics expenses percentage : 0.25%
Solution
#include <iostream>
using namespace std;
int main() {
int branding_expenses, travel_expenses, food_expenses, logistics_expenses;
cout << "Enter branding expenses" << endl;
cin >> branding_expenses;
cout << "Enter travel expenses" << endl;
cin >> travel_expenses;
cout << "Enter food expenses" << endl;
cin >> food_expenses;
cout << "Enter logistics expenses" << endl;
cin >> logistics_expenses;
float total_expenses = branding_expenses + travel_expenses + food_expenses + logistics_expenses;
float branding_expenses_percentage = (float)branding_expenses / total_expenses * 100;
float travel_expenses_percentage = (float)travel_expenses / total_expenses * 100;
float food_expenses_percentage = (float)food_expenses / total_expenses * 100;
float logistics_expenses_percentage = (float)logistics_expenses / total_expenses * 100;
printf("Total expenses : Rs.%.2f\n", total_expenses);
printf("Branding expenses percentage : %.2f%%\n", branding_expenses_percentage);
printf("Travel expenses percentage : %.2f%%\n", travel_expenses_percentage);
printf("Food expenses percentage : %.2f%%\n", food_expenses_percentage);
printf("Logistics expenses percentage : %.2f%%\n", logistics_expenses_percentage);
return 0;
}
Happy Learning – If you require any further information, feel free to contact me.