# Need help with my arrayList

• February 9th, 2014, 11:20 PM
Dshelton
Need help with my arrayList
/************************************************** *******
* Create a project that takes a calculates commission
* Created by Daryal J Shelton
* Class PRG 420 Java Programming 1
* Instructor Don Mc Pherson
* Date 2/1/2014
************************************************** ******/

/************************************************** ******
*Start Program
************************************************** ******/

import java.util.ArrayList;
import java.util.Scanner;

public class Commission1
{
public static void main(String[] args)
{

ArrayList<Salesperson> cArray = new ArrayList<>();
Scanner keyboard = new Scanner(System.in);

double salary; // Yearly Salary
salary = 50000;
double income = 0;
double commissionRate = 0.05; // Commision @ 5%
double bigcommissionRate = 0.065; // Commission at 6.5%
double sales = 0;
double goalSales = 960000; //
double commision = commissionRate * sales;
double totalPay = salary + commision ; // Total salary with commision
double salesTarget = 1200000; // Gaol to get commission increase.
double saleTargetrate = sales * bigcommissionRate; // set sales comminssion
String salesperson2; // person that made the money
String name;
/************************************************** *********************
* THe ArrayList for two sales people
*
************************************************** ********************/
Commission salesPerson[] = new Commission[2];
salesPerson[0] = new Commission();
salesPerson[1] = new Commission();
salesPerson[2] = new Commission();
{
{
/************************************************** *******************
* Enter First sales person name and display a greeting message...
************************************************** *******************/
System.out.println("Hello Welcome To The Commission Calculator:");// greating message
System.out.print( "Please Enter First Sales Persons Name:" ); // name of User
salesPerson[0].name = keyboard.next();

/************************************************** ******************
* Yearly Salary
************************************************** ******************/
System.out.print( "Please enter The First Employees Yearly Salary: \$");
income = keyboard.nextDouble();

/************************************************** ******************
* Entering sales
************************************************** ******************/
System.out.print( "Please Enter Their Total Sales: \$" );
sales = keyboard.nextInt() ;
System.out.println();
}

{
/************************************************** ********************
* Sales person 2
************************************************** ********************/

System.out.println( "Please Enter Next Sales Persons Name:" ); // name of User
salesPerson[1].name = keyboard.next();

/************************************************** ******************
* Yearly
*Salary
************************************************** ******************/
System.out.println( "Your Base Salary is: \$");
income = keyboard.nextDouble();

/************************************************** ******************
* Entering sales
************************************************** ******************/
System.out.print( "Please Enter Their Total Sales: \$" );
sales = keyboard.nextInt() ;

}
/************************************************** ********************
* Loop starts here
************************************************** ********************/

}
if (sales < 96000) // Sales less than 80% of target

{
System.out.print("Their Sales Commission are: \$");
System.out.println(0.00);
System.out.println(" They Did Not Meet The Criteria To Earn A Commission.");
System.out.println("Better Luck Next Time.");
System.out.print("Their total Salary Is: ");
System.out.println(salary);
System.exit(0);
}
/************************************************** ***************
* If true program ends here if not carry on to the next loop
************************************************** **************/
{
if (sales < 120000) {
System.out.print("Their Sales Commission are: \$");
System.out.println(sales * commissionRate);
System.out.print("Their Total Earnings are: \$");
System.out.println(sales * commissionRate + salary);
System.exit(0);
} else {
if (sales >=120000){
System.out.print("Their Sales Commission are: \$");
System.out.println(sales * 0.065);
System.out.print("Their Total Earnings are: \$");
System.out.println(sales * 0.065 + salary);
System.exit(0);
}
}
}

}
}

/************************************************** ***********************
*End program!!!!!!
************************************************** ***********************/

--- Update ---

Im getting this error message

run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: Salesperson
at Commission1.main(Commission1.java:25)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
• February 10th, 2014, 12:00 AM
ankurt
Re: Need help with my arrayList
What do you mean by Salesperson at the time of declaration of ArrayList. Is it a class that you have created or are you referring to the array of object that you have instantiated of type "Commision"?
• February 10th, 2014, 12:29 AM
Parranoia
Re: Need help with my arrayList
You haven't defined the type Salesperson.
What was your intent for this line?
• February 10th, 2014, 01:17 AM
ankurt
Re: Need help with my arrayList
I think you need to change the type of the ArrayList to Commission, that should do.
• February 10th, 2014, 05:13 AM
GregBrannon
Re: Need help with my arrayList
Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.