Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 1st, 2006, 9:40 PM   #1
roniz
Newbie
 
Join Date: Nov 2006
Posts: 3
Rep Power: 0 roniz is on a distinguished road
Method/Loop?

For the last part of my problem I need to create another method called payroll that takes no parameters and loop it 4 times and in each pass, it should ask for sales amount for the week then calculate sales for the month by calling on bonus and commission?

I'm not sure how to go about it and I don't understand why payroll shouldn't have any parameters. How can it call on commission and bonus without them are parameters?

Also what kind of loop will be best suited for it? here's my code so far.

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


double amount; 
int years;
double ans;
double extra = 400;
double baseSalary = 500.00;
 

    	//Ask for amount
		System.out.print("Please enter sales amount for the week:  "); //Ask for amount
		amount = MyInput.readDouble(); //Store amount
		
		//Ask for years
		System.out.print("Please enter the number of years the sales person has been with the company:  "); 
		years = MyInput.readInt(); //Store amount
		
		double commission = commission(amount);
		
	double bonus = bonus(years, amount, baseSalary);
	double payroll = payroll(commission, bonus, amount);
		
	System.out.println("Your monthly salary is $" + payroll  );
}	
	public static double commission(double amount)
      {

           	if  (amount >= 5000) { //Calculate sales if amount entered is greater than or equal to 10001
		return (amount * 0.10)  + 400; 
	
	}	
		
		else if  (amount >= 1000 ){
		return (amount * .08); 		
		
		}
	
		else if  (amount >= 1000){
		return (amount * 0.08);
		
		}	
		
		else if   (amount >= 500 ){
		return(amount * .05);
	
		
		}
		
		else { return 0.0;
		

  }	
  	
  	}
  	
 public static double bonus(int years, double amount, double baseSalary)
 
      
      {

               if  (amount >= 5000 && years >= 2) {
        return (baseSalary + amount * years/100) ;
        
        
}
		
		else if  (amount >= 1000 && years >= 2){
		return (baseSalary + amount * years/100); 		
		
		}
	
		else if  (amount >= 500 && years >= 2){
		return (baseSalary + amount  * years/100);
		
		}	
		
		else if   (amount < 500&& years >= 2){
		return(baseSalary + amount  * years/100);
	
		
		}
		
    else { return baseSalary;
    }
    
        }
    
    




public static double payroll(double commission,double bonus, double amount)


{
	
	{

               if  (amount >= 5000 ) {
        return (commission + bonus) ;
        
        
}
		
		else if  (amount >= 1000 ){
		return (commission + bonus); 		
		
		}
	
		else if  (amount >= 500 ){
		return (commission + bonus);
		
		}	
		
		else if   (amount < 500){
		return(commission + bonus);
	
		
		}
		
    else { return 500.00;
    }
    
        }
	
	
	
}
}

//}
	
    
		 /**
		  	if  (amount >= 5000 && years >= 2) { //Calculate sales if amount entered is greater than or equal to 10001
		ans =  (amount * 0.10) + (baseSalary + 400);  
		ans = (ans * years/100) + ans;
		
		}
	
		else if  (amount >= 5000 && years < 2){
		ans =  (amount * 0.10) + (baseSalary + 400);
				
		}	
		
		else if  (amount >= 1000 && years >= 2){
		ans = (amount * .08) + baseSalary * (years/100);
		ans = (ans * years/100) + ans;
		
		}
	
		else if  (amount >= 1000 && years < 2){
		ans =  (amount * 0.08) + baseSalary;
		
		}	
		
		else if   (amount >= 500 && years >= 2){
		ans = (amount * .05) + baseSalary * (years/100);
		ans = (ans * years/100) + ans;

		}
	
		else if  (amount >= 500 && years < 2){
		ans =  (amount * 0.10) + baseSalary;
		
		}		
		
		else if (amount < 500&& years >= 2){  
		ans = baseSalary;
		
		}
		
		else { ans = baseSalary;
		
		}*/
roniz is offline   Reply With Quote
Old Nov 2nd, 2006, 4:30 AM   #2
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Not enough information to make a judgement. If you're not going to use parameters, the only option is to set up a few variables as class members. I also suppose the "loop it 4 times" could mean that you need to return the first four months salary, in which case a for-loop would look a likely candidate, but it's difficult to know for sure.

Perhaps if you could give the exact text of the problem?
Arevos is offline   Reply With Quote
Old Nov 2nd, 2006, 9:21 AM   #3
roniz
Newbie
 
Join Date: Nov 2006
Posts: 3
Rep Power: 0 roniz is on a distinguished road
It seems as though I was misunderstanding what we had to do XD it was pretty simple and I worked it out. Thank you so much though.
roniz is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:07 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC