Parameters Problems Help!!!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Parameters Problems Help!!!

  1. #1
    Join Date
    Dec 2008
    Posts
    5

    Parameters Problems Help!!!

    Hey guys i was hoping for someone to help me with my code. I'm having some difficulties with connecting the parameters.. I keep getting "cannot be applied to" error.. Can someone help? I have only done one output
    Here is my code:
    Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    package bmc;
    import keyb.InOut; // Import Keyboard Class to library 
    
    public class Payroll {
        
          //Main Menu Module
        static void displayMenu ()
        {
            System.out.println("Menu Screen");
            System.out.println("");
            System.out.println("Choice\t\tAction");
            System.out.println("1\t\tAll Employee details ");
            System.out.println("2\t\tEmployees whose monthly sales where above £10,000");
            System.out.println("3\t\tEmployees whose monthly sales are below the average");
            System.out.println("4\t\tEmployee with the highest monthly sales");
            System.out.println("5\t\tExit");      
        } // end of displayMenu
        
        
       //DisplayEmployee Module  
        static void DisplayEmployees ( int[] RefNo, String[] Name, int [] MonthlySales,int[] mark,
         int[] GrossPay, int[] Deductions, int[] NetPay, int lowValue,int NOE, int HighValue, String message)
              {
           
             // Print parameter message
            System.out.println("\n\n"+ message+"\n");
            System.out.println("RefNo \t\t Name \t\t Monthly Sales");
           
             // Declare a variable index and Number of employees
            int index;
            
            
            // Loop through the whole array and decide whether to print employee details*
            for (index = 0; index <= NOE - 1; index = index ++)
            {
                if ((mark[index] >= lowValue) && (mark[index] < HighValue))
                {
                    System.out.println(RefNo[index] + "\t\t\t" + Name[index] + MonthlySales[index]
                            + GrossPay[index]+Deductions[index]+ NetPay[index]);
                } 
        } //end of for loop
        }// end of module 
         
        //AverageResult Module 
        static int AverageResult(int[] MonthlySales, int howMany)
        {
            // declare varibles 
            int totalSales, average,index;
            
            totalSales=0;
            
            // for loop 
            for (index = 0; howMany <= -1; index++)
                if (howMany<= -1)   
                {
                    totalSales= totalSales + MonthlySales[index];
                }//end of for loop
            
            totalSales = totalSales+ MonthlySales [index];
            average=  totalSales/howMany ;
            
           //Return average to get to main method 
            return average ;
           }// end of 
        public static void main(String [] args ) {
       
        //Declare and initalise arrays 
           int [] RefNo = {1000,2571,4002,1303,1004,1005};
           String [] Name = {"Barnes,Chris", "Pollock,Daniel", "McManus,John", "Martin,Jean", "Goody,Rosemary", 
            "Cage,Liam"};
           int[] MonthlySales  = {10000,9990,4000,15000,4900,6000};
           
           //Declare arrays
           int Commission[],Deductions[],GrossPay[],NetPay[];
           //Declare varibles 
           int AverageSales,menuOption,menuValid,Count;
           double HighestSales;
           
           //Declare Constant
          int StaffBasic = 600;
          int DeductionsPercentage = 35;
          int HighComRate = 12;
          int LowComRate = 7;
          int NumberOfEmployees = 6;
           
           HighestSales=0.0;
           Count= 0;
           
           // Loop 6 Employees
           for (NumberOfEmployees = 1; NumberOfEmployees<=6; NumberOfEmployees++ )
           {
               System.out.println("Ref No: " + RefNo[Count]);
               System.out.println("Name: "+Name[Count]);
           }
           // User enters in monthly sales 
           MonthlySales[Count]=InOut.readInt();
           
          // While Loop 
           while ((MonthlySales[Count] <0) || (MonthlySales[Count] >20000))
           { // start of while loop
               System.out.println("Invalid value. Should be in the range 0-20000! ");
               System.out.println("Re-enter the sales persons monthly sales ");
               MonthlySales[Count]=InOut.readInt();
           } // end of while loop
           
           //if loop
           if  (MonthlySales[Count] >=10000)
           
           {
               Commission[Count]= MonthlySales[Count] * HighComRate/100;
               GrossPay[Count] = StaffBasic +   Commission[Count];
               Deductions[Count] = GrossPay[Count] * DeductionsPercentage/100;
               NetPay[Count] = GrossPay[Count] - Deductions[Count];    
           }
           
           else
           {
               Commission[Count]= MonthlySales[Count] * LowComRate/100 ;
               GrossPay[Count] = StaffBasic + Commission[Count];
               Deductions[Count] = GrossPay[Count] *  DeductionsPercentage/100;
               NetPay[Count] = GrossPay[Count] - Deductions[Count];
           } 
           
           if (MonthlySales[Count] > HighestSales)
           {
               HighestSales = MonthlySales[Count];
           }
           
           Count = Count + 1;        
          
            // Call method to display menu
            displayMenu();
            
            // Input menu option
            System.out.println("\nEnter menu option:");
            menuOption = InOut.readInt();
            
            // If invalid menu option     
                while ((menuOption <1)||(menuOption >5))
                {
                    System.out.println("\nInvalid value. Should be in the range 1-5!");
                    System.out.println("\nPlease select again from the list below:\n");
                    displayMenu ();
                    System.out.println("\nEnter menu option:");
                    menuOption = InOut.readInt();           
                } // End of while construct           
                
                // Loop until user chooses 5 to exit
                while (1 == 1)    
                {
                    // Process option chosen by user
                    switch (menuOption)
                    {
                        // Process menu option to display all Employee Details 
                        case 1 : DisplayEmployees (RefNo,Name, MonthlySales,GrossPay,Deductions,NetPay,0, 20000, "All Employee Details");            
                        break;
            
                        /*Process menu option to display all Employees whoses monthly
                         * sales where above &#163;10,000*/             
                        case 2 :    
                                    break; 
                         
                        /* Process menu option to display all Employees whose monthly
                         * sales where below average*/
                        case 3 :   
                                    break;
                 
                        // Process menu option to display the Employee with highest monthly sales
                        case 4 :    
            
                                   
                                    break;
                        
                        // Process exit option
                        case 5 :   System.exit (0);
                                    break;
                        
                        // Process option for invalid menu option
                        default :   System.out.println("\nInvalid value. Should be" +
                                    " in the range 1-5!");
                                    System.out.println("\nPlease select again from" +
                                    " the list below:\n");
                                    displayMenu ();
                                    System.out.println("\nEnter menu option:");
                                    menuOption = InOut.readInt();
                    } // end of switch construct
                    
                    System.out.println("\nPlease select again from the list below:\n");
                    displayMenu ();
                    System.out.println("\nEnter menu option:");
                    menuOption = InOut.readInt(); 
                    
                } // End of while construct   
            
        } // End of main method
    } //End of Class
    Last edited by Hack; 12-22-2008 at 12:36 PM. Reason: Added Code Tags

  2. #2
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    u get this error pointing to which line? or attach the keyb class to run the file and test the code ...
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

  3. #3
    Join Date
    Dec 2008
    Posts
    5
    hey, i fixed the problem i was running into.. but now i have another problem, its telling me i have to initilize my arrays but the thing is i don't want to initilize the arrays. does that make sense.. its line 81 i'm having problems with now!

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    First, please post what you did to fix the problem. It could help someone else with the same or similiar problem.

    Second, I'm not going to count each line of the code you posted to figure out which one is line 81.

    When you say it is "telling me I have to initilize my arrays" what does that mean? Are you getting some kind of error message?
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  5. #5
    Join Date
    Oct 2005
    Location
    Maady
    Posts
    1,819
    I agree with hack, u have to tell us where is this line,
    for the question "I have to initilize my arrays", depends on which situation but generally this works:

    Code:
    int[] x; //un-initialized
    x=new int[50]; //OK (init-before use, MUST)
    x[7]=70; //use and access elements OK
    Programmer&Cracker CS
    MyBlog:Blog.Amahdy.com
    MyWebsite:www.Amahdy.com

Similar Threads

  1. Replies: 5
    Last Post: 06-27-2008, 06:27 PM
  2. ADO and stored proc parameters data type problem
    By markus in forum VB Classic
    Replies: 13
    Last Post: 01-29-2007, 11:23 AM
  3. Passing Multiple Parameters to a DLL function
    By wandera in forum VB Classic
    Replies: 4
    Last Post: 11-25-2005, 03:11 AM
  4. Replies: 0
    Last Post: 06-04-2001, 10:17 AM
  5. Replies: 2
    Last Post: 05-09-2001, 01:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center