Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Need help with my arrayList

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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)


  2. #2
    Member
    Join Date
    Feb 2014
    Location
    India
    Posts
    47
    My Mood
    Bored
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Default 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"?

  3. #3
    Member
    Join Date
    Apr 2012
    Posts
    160
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Default Re: Need help with my arrayList

    You haven't defined the type Salesperson.
    What was your intent for this line?

  4. #4
    Member
    Join Date
    Feb 2014
    Location
    India
    Posts
    47
    My Mood
    Bored
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Default Re: Need help with my arrayList

    I think you need to change the type of the ArrayList to Commission, that should do.

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default 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.

    Please post your code correctly. You can even edit your post and fix it.

Similar Threads

  1. How to use an ArrayList and what is its advantage over array?
    By JavaPF in forum Java SE API Tutorials
    Replies: 4
    Last Post: December 21st, 2011, 04:44 AM
  2. private Map<String, ArrayList> xlist = new HashMap<String, ArrayList>();
    By Scotty in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 21st, 2011, 08:37 AM
  3. Ordering ArrayList by 3 conditions as you add to ArrayList
    By aussiemcgr in forum Collections and Generics
    Replies: 4
    Last Post: July 13th, 2010, 02:08 PM
  4. [SOLVED] Extracting an How to ArrayList from an ArrayList and convert to int??
    By igniteflow in forum Collections and Generics
    Replies: 2
    Last Post: August 16th, 2009, 01:11 PM
  5. How to use an ArrayList and what is its advantage over array?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 1
    Last Post: May 17th, 2009, 01:12 PM