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 10 of 10

Thread: PLEASE HELP!!!!

  1. #1
    Junior Member
    Join Date
    Aug 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Angry PLEASE HELP!!!!

    Using Netbeans IDE

    This is my fourth week of Java coding in class, so I'm fairly new to programming.

    My assignment is to calculate information of band member and sales. i have to compare sales of more then one group of band using an array, calculate sales buy the user entering information and compare by which band is the lowest and highest.

    NetBeans is saying I have errors of " cannot find symbol" but I am coding by my chapters and I am still confused.

    I know that some code is not in the right place because when I put some methods in certain places, netbeans agree with some of the codes, but dont like where I but other parts of the codes.
    so right now I am aware that certain pieces of the codes are in the wrong place but only because it helps the rest of the coding in the right places, (kind of confusing but its true)
    Here is my code:
    package concertbookings4;
     
    //imports scanner input.
    import java.util.Scanner;
     
    // imports decmial format.
    import java.text.DecimalFormat;
     
     
    public class CB4 
     
     
    {
            // stores value for band as highest selling band
            public double getHighest()
            {   
                return highest;
            }            
     
              double highest = bands[0]; 
     
              { 
                // stores value for band as lowest selling band  
              }     
            public double getLowest()
     
            {
                return lowest;
            }
                  double lowest = bands[0];  
     
        //Get items for each band.
        private void getItems(CB4[]array)
        { 
             String name;
     
             int albums,amountBandMem =0, amountOfAttendees;
             // 1)Number of Band Members 
             // 2) Amount of Attedees
     
             double ticketPrice=0 , extraPayment  , incentiveAmount , 
                    amtPerBanMember =0, totalRate=0  ;
     
                 // 1)Ticket Price 2)Extra Payment of 15% from ticket price
             //3) Incentive Amount for each additiona Attendee
             //4) The amount per band member
            // 5) Total rate is the amount of incentive amount plus flat rate.
     
     
              int ticketAmount=0; //the amount of tickets
     
            double ticketSales; // the amount of tickets sold based by the amount of the
                           //attendees and price of the tickets.
                   /*
            * Calculation for flat rates, percentage, and acceleration factor.
            */ 
            double FRate = 350.00,
               FRate2 = 575.00,
               FRate3 = 850.00; //Flate rate to band that sold 5 or more albums.
     
        float percentage; //Percentage is 15%
     
        percentage = 0.15F;
     
        float AccFactor = 33.75F;//acceleration factor
     
         extraPayment = percentage * ticketPrice; // or
     
             extraPayment = AccFactor * ticketPrice;
     
     
         //This calculates exta payment multiply by amount of attendees = 
         //incentive amount.
         incentiveAmount = extraPayment * ticketAmount;
     
     
    //this calculates how much each band member will get from the     
         //incentive amount.
         amtPerBanMember = totalRate/ amountBandMem;
     
     
        }     
     
        // Declare money format output
        DecimalFormat money = new DecimalFormat("$#,###.00");
     
      //Creates Scanner input
        public Scanner input = new Scanner(System.in);
     
        {
            //allows enteries of three bands.
       final int BANDS = 3;
     
       //creates CB4 array.
       CB4[]bands = new CB4 [BANDS];
     
       // calls getItems method to retrieve data for each object.
      getItems(bands);
     
     
     
            //displays messages.
     System.out.println("This program will ask for information of three bands"+
                 " and compare their concert sales.");
     
     System.out.println("Welcome, The concert has changed its policy to a " +
            " new compensation of the band's requirement.");
     
     
                //*****************************************************************
     
     
            // get data for array.
            for(int index = 0; index < bands.length; index ++)
            {
                // Enters Band Name
            System.out.println("Enter Band's Name " + (index + 1));
            name[index] = input.nextLine();
     
             //Enters amount of members in the Band.
            System.out.println("Enter the amount of members in the band " + (index + 1));
            amountBandMem[index] = input.nextInt();
     
            //Enters the amount of attendees
            System.out.println("NOTE: The amount of attendees should be the same amount"
                + " as tickets solds! " + (index + 1));
     
            System.out.println("What is the amount of attendees?" + (index + 1));
            amountOfAttendees[index] = input.nextInt();
     
     
            //asks how many tickets where sold.
            System.out.println("How many tickets where sold at the concert?" + (index + 1));
            ticketAmount[index]= input.nextInt();
     
     
              //Enters the ticket price
             System.out.println("What is the amount of the ticket price?" + (index + 1));
            ticketPrice[index] = input.nextDouble();
     
          /*enters the amount of albums prior sold.
          * This also means that for one ticket sold per attendee.
          * one ticket = one attendee
         */
            System.out.print("Enter the amount of albums sold. " + (index + 1));
            albums[index] = input.nextInt();
     
            //Creates CB4 object inialized with data and store the object in array.
           bands[index]= new CB4(name,amountBandMem,amountOfAttendees, ticketAmount,ticketPrice,albums);
     
            }
     
            //display data entered by the user.
            for(int index = 0; index < bands.length; index ++)
            {
                System.out.println("Name: " + CB4[index].getname());
     
                System.out.println("Number of members: " + CB4[index].getamountBandMem());
     
                System.out.println("Amount of Attendees: " + CB4[index].getamountOfAttendees());
     
                System.out.println("Amount of tickets: " + CB4[index].getticketAmount());
     
                System.out.println("Price of tickets: " + CB4[index].getticketPrice());
     
                System.out.println("Albums Sold: " + CB4[index].getalbums());
            }  
           //*****************************************************************
     
     
            //loop for the array bands for albums of each band.
     
            for(int index = 0; index < bands.length; index ++)
         {
     
        /*
         * This condition will set the flate rate based on how many albums the band
         * has sold and is well known in the industry.
         */
     
          if (albums <= 1 ) // if albums sold are less than or equal to one.
        {
     
        /*
         * This condition will set the flate rate based on how many albums the band
         * has sold and is well known in the industry.
         */
     
          if (albums <= 1 ) // if albums sold are less than or equal to one.
            {
            FRate = 350.00;
     
            System.out.println(" The Bands pay rate will be" + money.format(FRate));
     
            totalRate = incentiveAmount + FRate;
     
            }
     
            else 
             {
                if (albums >2 && albums < 4)// albums sold are greater than 2 or less 
                                        // 4
             { FRate2 = 575.00;
     
                System.out.println(" The Bands pay rate will be" + money.format(FRate2));
                  totalRate = incentiveAmount + FRate2;
             }
     
                else
                    {
                        if (albums >= 5)// albums that are sold 5 or more
     
     
                        { 
                            FRate3 = 850.00;
                            System.out.println(" The Bands pay rate will be" + money.format(FRate3));
                           totalRate = incentiveAmount + FRate3;
                        }        
     
     
     
        if ( ticketAmount ==200)//condition on the amount of tickets sold of 200 
                              // more.
            {  
            extraPayment = percentage * ticketPrice;
     
            }
            else
                 {
     
     
            if (ticketAmount > 200)
                    {
                    extraPayment =  accelerationfactor * incentiveAmount;
     
                    }
                 }
               }
            }
          }
        }
           //*****************************************************************
     
     
           //loop for highest selling band.
          for(int index = 0; index < bands.length; index ++)
            {
                if (bands[index]> highest)
                    highest = band[index];
            }
     
     
                // loop to calculate the lowest seller       
                for(int index = 0; index < bands.length; index ++)
            {
                if (bands[index]< lowest)
                    lowest = bands [index];
            }
    Last edited by helloworld922; August 14th, 2013 at 03:51 AM. Reason: please use [code] tags

  2. #2
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: PLEASE HELP!!!!

    Hello.
    Do you have any specific question regarding your code?

    Syed.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,854
    My Mood
    Mellow
    Thanks
    239
    Thanked 721 Times in 707 Posts

    Default Re: PLEASE HELP!!!!

    Please post the entire error message, not just the shortened "cannot find symbol." Perhaps if you show us the message, we can explain to you what it means and how to use it (and others) to fix the errors yourself.

  4. #4
    Junior Member
    Join Date
    Aug 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: PLEASE HELP!!!!

    here is the file using Netbeans.

    If you do not use netbeans then you may not be able to help
    Attached Files Attached Files

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,854
    My Mood
    Mellow
    Thanks
    239
    Thanked 721 Times in 707 Posts

    Default Re: PLEASE HELP!!!!

    The code in the Netbeans project you posted - not the error message like I asked - is missing a few close braces. So is the code you posted in your first post. Why is that?

    Have you tried to compile the project? If so, copy and paste the resulting error message and stack trace. If you haven't tried to compile and you're asking about a Netbeans message given prior to compiling in a red squiggly or similar, you should explain that.

  6. #6
    Junior Member
    Join Date
    Aug 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: PLEASE HELP!!!!

    oh sorry yes, I am asking that most of the red line are because of the error saying" cannot find symbol" but I dont know why because all my variables are declared.

    so you are saying maybe cause im missing some braces?

    --- Update ---

    yes its the same code I posed in the first message

    --- Update ---

    I cannot compile the program because it wont work if I have those red lines

  7. #7
    Junior Member
    Join Date
    Aug 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: PLEASE HELP!!!!


  8. #8
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,854
    My Mood
    Mellow
    Thanks
    239
    Thanked 721 Times in 707 Posts

    Default Re: PLEASE HELP!!!!

    I'm not sure you're right about all variables being declared. I see ~30+/- complaints about variables that haven't been declared. For example: bands, name, amountBandMem, amountOfAttendees, ticketAmount, ticketPrice, albums, CB4 (bad name), etc. Where have those variables been declared?

  9. #9
    Junior Member
    Join Date
    Aug 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: PLEASE HELP!!!!

    they are declared here:

    private void getItems(CB4[]array)
    {
    String name;

    int albums,amountBandMem =0, amountOfAttendees;
    // 1)Number of Band Members
    // 2) Amount of Attedees

    double ticketPrice=0 , extraPayment , incentiveAmount ,
    amtPerBanMember =0, totalRate=0 ;

    // 1)Ticket Price 2)Extra Payment of 15% from ticket price
    //3) Incentive Amount for each additiona Attendee
    //4) The amount per band member
    // 5) Total rate is the amount of incentive amount plus flat rate.


    int ticketAmount=0; //the amount of tickets

    double ticketSales; // the amount of tickets sold based by the amount of the
    //attendees and price of the tickets.


    float percentage; //Percentage is 15%

    percentage = 0.15F;

    float AccFactor = 33.75F;//acceleration factor

    extraPayment = percentage * ticketPrice; // or

    extraPayment = AccFactor * ticketPrice;


    //This calculates exta payment multiply by amount of attendees =
    //incentive amount.
    incentiveAmount = extraPayment * ticketAmount;


    //this calculates how much each band member will get from the
    //incentive amount.
    amtPerBanMember = totalRate/ amountBandMem;


    }

  10. #10
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,854
    My Mood
    Mellow
    Thanks
    239
    Thanked 721 Times in 707 Posts

    Default Re: PLEASE HELP!!!!

    Those variables are declared INSIDE a method so are LOCAL to that method, invisible to references to those LOCAL variables OUTSIDE that method. To declare them so that they can be seen throughout the class, you'd declare them as instance variables as in:
    public class CB4 
    {
        //declare instance variables, initialize constants as needed:
        //allows enteries of three bands.
        final int BANDS = 3;
     
        //creates CB4 array.
        CB4[]bands = new CB4 [BANDS];
     
        String name;
     
        int albums,amountBandMem =0, amountOfAttendees;
        // 1)Number of Band Members 
        // 2) Amount of Attedees
     
        double ticketPrice=0 , extraPayment  , incentiveAmount , 
                amtPerBanMember =0, totalRate=0  ;
     
        // 1)Ticket Price 2)Extra Payment of 15% from ticket price
        //3) Incentive Amount for each additiona Attendee
        //4) The amount per band member
        // 5) Total rate is the amount of incentive amount plus flat rate.
     
     
        int ticketAmount=0; //the amount of tickets
     
        double ticketSales; // the amount of tickets sold based by the amount of the
        //attendees and price of the tickets.
        /*
         * Calculation for flat rates, percentage, and acceleration factor.
         */ 
        double FRate = 350.00,
                FRate2 = 575.00,
                FRate3 = 850.00; //Flate rate to band that sold 5 or more albums.
     
        float percentage; //Percentage is 15%
     
        // etc . . . . .
    After you collect all of those undefined variables and declare them as instance variables, problems will persist so come back when you need more help.

  11. The Following User Says Thank You to GregBrannon For This Useful Post:

    Peachweb77 (August 14th, 2013)