Here is the Data:
Department Name: Cool Casino
# of Employees: 543
Cost Per Employee: 0.75
Sales: 1000.432Department Name: Trumpola Burgers
# of Employees: 43
Cost Per Employee: 19.725
Sales: 50Department Name: Donoldio Clothing for Cats
# of Employees: 4.0001
Cost Per Employee: 5.233
Sales: 100Department Name: Trumpola Leaning Tower
# of Employees: 1003
Cost Per Employee: 1.2123
Sales: 704.67Bonus: Use a loop to ask how many departments Donaldio would like entered and then loop through that many requests!
Further Explanation of Assignment:
In this assignment you will use the concepts you have learned from "Input and Output."
1. Importing Packages
2. Reading Information
3. Converting Information
4. Formatting OutputAssignment Background:
Billionaire Donaldio Trumpola has hired you to help him run his many businesses. He has so many staff members in so many different companies that he is losing track of them all. What he would like you to do, is write a program, that he can use to enter in the information about his companies. He will want to input the following information for each department:
Department Name:
Employees:
Cost Per Employee:
Sales:Below is the data he would like you to enter (you didn't think he would enter it himself did you?) Write your program to handle the amount of information that needs to be inputted. You do not need to use a loop, you can simply have multiple requests to ".readLine()" .
Finally, Donaldio would like your program to use all the information inputted to find out if he has made any money, or if he is bankrupt. Calculate the cost to run each department, and compare that to the sales for the department, come up with a total, and present all your numbers in a nice output that has been formatted - using the technique you have learned in the notes - to show money with two decimal places, comma's and a dollar sign. In the output you should present the statistics for each department, and the statistic for all departments.
The Code:
-------------------------------------------------------------------------------------------------
import java.io.* ;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class JavaApprentice {public static void main(String args[])
{
InputStreamReader istream = new InputStreamReader(System.in) ;BufferedReader bufRead = new BufferedReader(istream) ;
System.out.println("Welcome To Java Apprentice!");
double val1 = 00.00;
double val2 = 00.00;
double val3 = 00.00;
double val4 = 00.00;
double val5 = 00.00;
double val6 = 00.00;
double val7 = 00.00;
double val8 = 00.00;
double val9 = 00.00;
double val10 = 00.00;
double val11 = 00.00;
double val12 = 00.00;
double val14 = 00.00;
try{
System.out.println("Please Enter In Your Department Name: ");String firstDepartment = bufRead.readLine();
System.out.println("Please Enter In The # of Employees: ");
val1 = Double.parseDouble(bufRead.readLine());;
System.out.println("Please Enter In The Cost Per Employee: ");
val2 = Double.parseDouble(bufRead.readLine());
System.out.println("Please Enter In Sales: ");
val3 = Double.parseDouble(bufRead.readLine());
System.out.println("You're " + firstDepartment + ", Profit is: " + "$" + (val1 * val2 - val3));
System.out.println("Please Press Enter!");
String firstEnter = bufRead.readLine();
System.out.println("Please Enter In Your Department Name: ");
String secoundDepartment = bufRead.readLine();
System.out.println("Please Enter In The # of Employees: ");
val4 = Double.parseDouble(bufRead.readLine());;
System.out.println("Please Enter In The Cost Per Employee: ");
val5 = Double.parseDouble(bufRead.readLine());
System.out.println("Please Enter In Sales: ");
val6 = Double.parseDouble(bufRead.readLine());
System.out.println("You're " + secoundDepartment + ", Profit is: " + "$" + (val4 * val5 - val6));
System.out.println("Please Press Enter!");
String secoundEnter = bufRead.readLine();
System.out.println("Please Enter In Your Department Name: ");
String thirdDepartment = bufRead.readLine();
System.out.println("Please Enter In The # of Employees: ");
val7 = Double.parseDouble(bufRead.readLine());;
System.out.println("Please Enter In The Cost Per Employee: ");
val8 = Double.parseDouble(bufRead.readLine());
System.out.println("Please Enter In Sales: ");
val9 = Double.parseDouble(bufRead.readLine());
System.out.println("You're " + thirdDepartment + ", Profit is: " + "$" + (val7 * val8 - val9));
System.out.println("Please Press Enter!");
String thirdEnter = bufRead.readLine();
System.out.println("Please Enter In Your Department Name: ");
String fourthDepartment = bufRead.readLine();
System.out.println("Please Enter In The # of Employees: ");
val10 = Double.parseDouble(bufRead.readLine());;
System.out.println("Please Enter In The Cost Per Employee: ");
val11 = Double.parseDouble(bufRead.readLine());
System.out.println("Please Enter In Sales: ");
val12 = Double.parseDouble(bufRead.readLine());
System.out.println("You're " + fourthDepartment + ", Profit is: " + "$" + (val10 * val11 - val12));
System.out.println("Please Press Enter!");
String pressEnter = bufRead.readLine();
System.out.println("Hello, Donaldio. Your Final Financial Profit of all Departments are: " + "$" + (val1 * val2 - val3 + val4 * val5 - val6 + val7 * val8 - val9 + val10 * val11 - val12));
String pleaseContinue = bufRead.readLine();
}
catch (IOException err) {
System.out.println("Error reading line");
}
catch(NumberFormatException err) {
System.out.println("Error Converting Number");
}}
}
-------------------------------------------------------------------------------------
I have handed it in and gotten this reply from my teacher:
1) Profit = Sales -Cost (you have the incorrect equation)
2) Your program must handle multiple departments and give the final financial position for Donaldio.
It does work otherwise, but lacks the inhibition of what he says is the wrong equation and I need to handle multiple departments. So what am I doing wrong? *looking for simple Java, Nothing beyond If Else Etc...