Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 9:43 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 6 posts ] 
Author Question
 Question subject: Salary of each sales person
PostPosted: Sat Jun 23, 2007 1:21 pm 
Offline
Newbie
User avatar

Joined: Sat Jun 23, 2007 12:44 pm
Posts: 8
Has thanked: 0 time
Have thanks: 0 time

The following file has the problem and the solution, however I can getting the following error "cannot find symbol variable math" when compiling. Where am I going wrong at?
Bama

(Sales Commissions) Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9% of $5000, or a total of $650. Write an application (using an array of counters) that determines how many of the salespeople earned salaries in each of the following ranges (assume that each salesperson's salary is truncated to an integer amount):
1. $200-299
2. $300-399
3. $400-499
4. $500-599
5. $600-699
6. $700-799
7. $800-899
8. $ 900-999
9. $1000 and over
Summarize the results in tabular format

Code:
// Determining how many sales person earn salaries
public class Salary
{
    public static void main (String args [])
    {
        // intializer list specifies the integers amount
        double salary [] = { 0, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200};
        int value []= new int [11];
        System.out.printf( "%s:%20s:\n", "Index", " Value"); // column heading
       
        for (int index = 0; index < (salary.length); index++)
        {
           if (10<=(int)math.floor(((salary[index]*(.9)+200)*.01)))
               ++value[10];
               
            else
               ++value[(int)math.floor(((salary [index]* (.9)+200)*.01))];
        }
           
        for (int index1 =2; index1<value.length-1; index1++)
           System.out.printf("$%5d-%5d: %10d\n",
           index1 *100,index1 * 100 + 99, value[index1]);     
       

        // output each salary element's value.
        for (int index2 =11; index2<= value.length; index2++ )
             System.out.printf( "$%5d%5s: 20d\n", index2*100-100, "& more", value[10]);

    } // end main
} // end class Salary


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Salary of each sales person
PostPosted: Sat Jun 23, 2007 1:50 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
The class is called Math no math , :gOOd:
Code:
public class Salary
{
    public static void main (String args [])
    {
        // intializer list specifies the integers amount
        double salary [] = { 0, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200};
        int value []= new int [11];
        System.out.printf( "%s:%20s:\n", "Index", " Value"); // column heading
       
        for (int index = 0; index < (salary.length); index++)
        {
           if (10<=(int)Math.floor(((salary[index]*(.9)+200)*.01)))
               ++value[10];
               
            else
               ++value[(int)Math.floor(((salary [index]* (.9)+200)*.01))];
        }
           
        for (int index1 =2; index1<value.length-1; index1++)
           System.out.printf("$%5d-%5d: %10d\n",
           index1 *100,index1 * 100 + 99, value[index1]);     
       

        // output each salary element's value.
        for (int index2 =11; index2<= value.length; index2++ )
             System.out.printf( "$%5d%5s: 20d\n", index2*100-100, "& more", value[10]);

    } // end main
} // end class Salary

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Salary of each sales person
PostPosted: Sat Jun 23, 2007 2:12 pm 
Offline
Newbie
User avatar

Joined: Sat Jun 23, 2007 12:44 pm
Posts: 8
Has thanked: 0 time
Have thanks: 0 time
Your reply is confusing. The class is salary and not math. Please explain further. Thanks


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Salary of each sales person
PostPosted: Sat Jun 23, 2007 2:24 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
In your code you wrote :

Code:
  if (10<=(int)math.floor(((salary[index]*(.9)+200)*.01)))


and must be
Code:
if (10<=(int)Math.floor(((salary[index]*(.9)+200)*.01)))


you used the class "math" .Must be "Math".

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Salary of each sales person
PostPosted: Mon Jun 25, 2007 6:38 pm 
Offline
Newbie
User avatar

Joined: Sat Jun 23, 2007 12:44 pm
Posts: 8
Has thanked: 0 time
Have thanks: 0 time
Hello are you still there?


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Salary of each sales person
PostPosted: Mon Feb 14, 2011 6:17 am 
Offline
Newbie
User avatar

Joined: Mon Feb 14, 2011 6:13 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time
import java.util.*;
public class Test{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.print("Enter number of Employee: ");
final int N = input.nextInt();
double sale[] = new double [N];
double [] wage = new double[N];
for (int i =0; i<sale.length; i++){
System.out.print("Enter sale for employer "+(i+1)+": ");
sale[i]=input.nextDouble();
wage[i]=getWage(sale[i]);

input.nextLine();
}
String [] header ={"$200-299","$300-399","$400-499","$500-599","$600-699","$700-799","$800-899","$900-999","$1000 and over"};
int counter [] = new int [9];
for( int i = 0; i < wage.length; i++){
System.out.println(wage[i]);
if (wage[i] <300){
counter[0]++;
}else if (wage[i] >= 300 && wage[i] < 400){
counter[1]++;
}else if (wage[i] >= 400 && wage[i] < 500){
counter[2]++;
}else if (wage[i] >= 500 && wage[i] < 600){
counter[3]++;
}else if (wage[i] >= 600 && wage[i] < 700){
counter[4]++;
}else if (wage[i] >= 700 && wage[i] < 800){
counter[5]++;
}else if (wage[i] >= 800 && wage[i] < 900){
counter[6]++;
}else if (wage[i] >= 900 && wage[i] < 1000){
counter[7]++;
}else { counter[8]++;

}
}
// print the result in tabular form
for (int i = 0 ;i < header.length; i++)
System.out.println(header[i]+" "+counter[i]);

}



public static double getWage(double sale){
double wage = 200 + (sale*0.09);
return wage;
}
}


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 6 posts ] 
Quick reply


  

 Similar topics
 Looking for sales agent for web development products
 Salary of each sales person

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: Google [Bot] and 3 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team