Click here to Skip to main content
15,881,881 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 double value that corresponds to the branding expenses.                                                                           
Second input is a double value that corresponds to the travel expenses.                                                                               Third input is a double value that corresponds to the food expenses.                                                                             Fourth input is a double value that corresponds to the logistics expenses. 

Output Format :                                                                       
First line of the output should display the double value that corresponds to the total expenses for the Event.
Next four lines should display the percentage rate of each of the expenses. Round off the output to two decimal digits.  
Refer to sample input and output for formatting specifications. 

Sample Testcases                                                                   
Input 1                                                 Output 1                       
20000                           Total expenses : Rs. 100000.00           
40000                           Branding expenses percentage : 20.00%   
15000                           Travel expenses percentage : 40.00%                           
25000                           Food expenses percentage : 15.00%  
                                Logistics expenses percentage : 25.00%


What I have tried:

package demo;

import java.util.Scanner;

public class DemoTranslation {
	public static void main(String[] args) {
		int b, t, f, l;
		float total;
		float b2, t2, f2, l2;
		System.out.println("Enter branding expenses");
		b = STDIN_SCANNER.nextInt();
		System.out.println("Enter travel expenses");
		t = STDIN_SCANNER.nextInt();
		System.out.println("Enter food expenses");
		f = STDIN_SCANNER.nextInt();
		System.out.println("Enter logistics expenses");
		l = STDIN_SCANNER.nextInt();
		total = b + t + f + l;
		System.out.printf("Total expenses : Rs.%.2f\n", total);
		b2 = (b / total) * 100;
		System.out.printf("Branding expenses percentage : %.2f%%\n", b2);
		t2 = (t / total) * 100;
		System.out.printf("Travel expenses percentage : %.2f%%\n", t2);
		f2 = (f / total) * 100;
		System.out.printf("Food expenses percentage : %.2f%%\n", f2);
		l2 = (l / total) * 100;
		System.out.printf("Logistics expenses percentage : %.2f%%\n", l2);
	}

	public final static Scanner STDIN_SCANNER = new Scanner(System.in);
}
Posted
Updated 29-Mar-22 21:21pm
Comments
Richard MacCutchan 19-Feb-22 6:28am    
What is the question?
Member 15540662 19-Feb-22 6:31am    
The above one Total expenses for the event.
Can you tell me what mistake I am doing?
Richard MacCutchan 20-Feb-22 3:40am    
The code works correctly as far as I can see. But you have still not explained what is wrong.
Uday Kiran 2022 23-Apr-22 7:29am    
Mark studies at Teswan National University. Now is the time for exam results. Mark hopes that his scores in 5 subjects in the exam could fetch him a scholarship for his GRE preparation.

The following simple rules are used to find whether he is eligible to receive the scholarship:

The University follows 5 point grading system. In an exam, a student can receive any score from 2 to 5. 2 is called an F grade, meaning that the student has failed that exam.
The student should not have failed any of the exams.
The Student must obtain a full score in some of his/her exams to show that he/she is excellent in some of the subjects.
He/She must have a grade point average not less than 4.
​You are given information regarding how Mark performed in those 5 subjects. Write a program to check whether he will receive the scholarship or not.
Richard MacCutchan 23-Apr-22 8:07am    
I don't think he will get the scholarship, unless he (and you) learns to do his own work.

Quote:
The above one Total expenses for the event.
Can you tell me what mistake I am doing?
If I copy and paste your code into an online IDE: Online Java Compiler - online editor[^] and run it with your inputs, I get your expected outputs:
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%
So ... what am I doing that you aren't?
 
Share this answer
 
v2
You can run your program on Interviewbit compiler, its showing error in Main.java:5.

Java
Main.java:5: error: class DemoTranslation is public, should be declared in a file named DemoTranslation.java


Whole Error:

Java
[CompilationError] Your code was terminated due to compilation error
Main.java:5: error: class DemoTranslation is public, should be declared in a file named DemoTranslation.java

public class DemoTranslation {

       ^

1 error
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900