Results 1 to 3 of 3
  1. #1
    aalloush is offline Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    Default Commission Program

    hello,
    this is the program i need to do:
    You have just started a sales job in a department store. You are a commission only employee.
    The commission paid each month based on monthly sales. The incremental commission rates are
    presented in the table below:

    Sales Amount Commission Rate
    $0.01 - $10,000 10%
    $10,000.01 - $30,000 15%
    $30,000.01 and Above 20%

    (e.g. if the monthly sales is $34,000 then the commission rate for the first $10,000 at 10%, the
    next $20,000 at 15% , and the remaining $4000 at 20%).
    As soon as you receive an income of $100,000 in the year, you like to a vacation in Honolulu,
    Hawaii for the rest of the year. The department store stops you from selling as soon as your
    monthly commission earnings cross $15,000 so that other sales persons get opportunity.
    Write a program that acts like a sales person (i.e. You); welcomes customers each month and
    sells merchandise to one customer at a time, respecting the monthly commission limit, until you
    reach the end of year or earning goal of $100,000 for the year; and sends you for a vacation in
    Honolulu if you achieve the goal, otherwise encourages you to enjoy in ur city.
    Your program should start with January. In any month, you can have several customers, and you
    are serving one customer at a time. Your program should ask the user if thereís a customer in the
    month, and generate a random amount of sales for the customer transaction. If thereís no
    customer in the month or monthly commission limit is reached, the program should move ahead
    to the next month. The program awards the commission (without any penalty) for the transaction
    thatís crossing the monthly commission limit. The program should print the commission
    earnings for the month while moving to the next month.
    here is my code:
    Java Code:
    import java.util.Scanner;
    
    import javax.swing.JOptionPane;
    
    public class ass2 {
    	private static int answer;
    
    
    
    	public static void main(String[] args){
    		
    		
    		new Scanner(System.in);
    		do{
    		//Welcome Message
    			System.out.println("Welcome To The Dunes Store.");
    	
    			int i;
    				for(i=1;i<=12;i++){
    					Month(i);
    				}
    		}while(answer==JOptionPane.YES_OPTION);
    	}
    	
    		
    	public static void Month(int month) {
    	    //double r;
    		switch(month) {
    	        case 1:
    	        	System.out.println("Welcome to January");
    	        	dialogue();
    	        	
    	        case 2:
    	        	System.out.println("Welcome to February");
    	        	dialogue();
    	        case 3:
    	        	System.out.println("Welcome to March");
    	        	dialogue();
    	        case 4:
    	        	System.out.println("Welcome to April");
    	        	dialogue();
    	        case 5:
    	        	System.out.println("Welcome to May");
    	        	dialogue();
    	        case 6:
    	        	System.out.println("Welcome to June");
    	        	dialogue();
    	        case 7:
    	        	System.out.println("Welcome to July");
    	        	dialogue();
    	        case 8:
    	        	System.out.println("Welcome to August");
    	        	dialogue();
    	        case 9:
    	        	System.out.println("Welcome to September");
    	        	dialogue();
    	        case 10:
    	        	System.out.println("Welcome to October");
    	        	dialogue();
    	        case 11:
    	        	System.out.println("Welcome to November");
    	        	dialogue();
    	        case 12:
    	        	System.out.println("Welcome to December");
    	        	dialogue();
    	            
    	        default:
    	           break;
    	    }
    	    }
    	
    
    static void dialogue (){
    
    		//Select the Random Number
    			double transaction = Math.random() * 50000.0;
    		
    		//Round the Random Number
    			transaction = Math.round(transaction*100)/100;
    		
    		//Asks for the customer
    			int answer = JOptionPane.showConfirmDialog(null,"Do we have a customer ?","Select Option ",JOptionPane.YES_NO_CANCEL_OPTION,
    					+ JOptionPane.QUESTION_MESSAGE);
    				
    					if(answer==JOptionPane.YES_OPTION){
    						
    						//Displays the items costs
    							JOptionPane.showConfirmDialog(null, "Those Items Costs " + transaction + " Do you Buy? ", "Select an Option : ", JOptionPane.YES_NO_CANCEL_OPTION,
    									+ JOptionPane.WARNING_MESSAGE) ;
    						
    							System.out.println("Transaction amount: " +transaction);
    							
    							System.out.println("transaction for this month: " +transaction);
    						}
    						
    						else {
    							System.out.println("Ok. See You Next Time. ");
    							System.exit(answer);
    						}
    					
    					
    				
    			}//End static void dialogue
    and i am working on the commission step but can not figure out how to do it:
    Java Code:
    import java.util.Scanner;
    
    
    
    public class test{
    
    public static void main(String[] args){
    
    	double num,num1,num2,num21,num3;
    	Scanner input = new Scanner(System.in);
    	
    	System.out.println("Input a number: ");
    	
    	num=input.nextInt();
    	
    	System.out.println("Number Entered: "+num);
    	
    	
    			
    			if (num>30000){
    				num3=(num-30000)*(20/100);
    			}
    				else if (num>=10000.01 && num<=20000){
    					
    					num2=(num-10000);
    					
    					if(num2<=20000){
    						num2=(num2)*(15/100);
    					}
    						
    				}
    			for(num>=0.01 && num<=10000.0){
    				
    				
    			}
    					
    }
    thanks for ur help.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default Re: Commission Program

    One problem I see is the code uses integer arithmetic: (15/100) returns a 0 because it does integer math. You could do the math yourself for that term and code: 0.15
    Check other parts of the code for the same type of mistake.
    If you want to get decimal places in a term, use a floating pt number: (15.0/100)
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    aalloush is offline Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    Default Re: Commission Program

    OK i did it.
    But now the only problem left is that i do not know where to put the do-while loop to keep asking for sale for the same month until it reaches 15000.
    then it has to jump to the next month until it comes to 100000 or to december.
    Java Code:
    import java.util.Scanner;
    
    import javax.swing.JOptionPane;
    
    public class ass2 {
    	private static int answer;
    	private static double total;
    
    
    	public static void main(String[] args ){
    		
    		new Scanner(System.in);
    		
    	
    		do{
    		//Welcome Message
    			System.out.println("Welcome To The Dunes Store.");
    	
    			int i;
    			
    				for(i=1;i<=12;i++){
    					//calls the function month from month 1 to 12 using switch 
    					Month(i);
    				}
    		}while(answer==JOptionPane.YES_OPTION);//as long as the answer is yes, the function month is called.
    	}
    	
    		
    	public static void Month(int month) {
    	    
    		switch(month) {
    	        case 1:
    	        	System.out.println("Welcome to January");
    	        	dialogue();
    	        	
    	        case 2:
    	        	System.out.println("Welcome to February");
    	        	dialogue();
    	        case 3:
    	        	System.out.println("Welcome to March");
    	        	dialogue();
    	        case 4:
    	        	System.out.println("Welcome to April");
    	        	dialogue();
    	        case 5:
    	        	System.out.println("Welcome to May");
    	        	dialogue();
    	        case 6:
    	        	System.out.println("Welcome to June");
    	        	dialogue();
    	        case 7:
    	        	System.out.println("Welcome to July");
    	        	dialogue();
    	        case 8:
    	        	System.out.println("Welcome to August");
    	        	dialogue();
    	        case 9:
    	        	System.out.println("Welcome to September");
    	        	dialogue();
    	        case 10:
    	        	System.out.println("Welcome to October");
    	        	dialogue();
    	        case 11:
    	        	System.out.println("Welcome to November");
    	        	dialogue();
    	        case 12:
    	        	System.out.println("Welcome to December");
    	        	dialogue();
    	            
    	        default:
    	           break;
    	    }
    	    }
    	
    
    static void dialogue (){
    	
    	
    	
    		//Select the Random Number
    			double transaction = Math.random() * 50000.0;
    			
    		//Round the Random Number
    			transaction = Math.round(transaction*100)/100;
    		
    		//Asks for the customer
    				
    					int answer = JOptionPane.showConfirmDialog(null,"Do we have a customer ?","Select Option ",
    							     JOptionPane.YES_NO_CANCEL_OPTION,
    								 JOptionPane.QUESTION_MESSAGE);
    				
    							if(answer==JOptionPane.YES_OPTION){
    								
    							
    									//Displays the items costs
    									JOptionPane.showConfirmDialog(null, "Those Items Costs " + transaction + " Do you Buy? ", "Select an Option : ", 
    									JOptionPane.YES_NO_CANCEL_OPTION,
    								    JOptionPane.WARNING_MESSAGE) ;
    							
    									
    									
    									System.out.println("Transaction amount: " +transaction);
    									
    									//calls the commission function:
    									commission(transaction);
    									
    									total=commission(transaction);
    									
    							        total+=total;
    									
    									System.out.println("Your total Commission For this month is: " +total);
    							
    								
    							}
    						
    						else {
    							System.out.println("Ok. See You Next Time. ");
    							System.exit(answer);
    						}
    						
    					
    				
    			}//End static void dialogue
    		
    
    
    
    public static double commission(double amount){
    
    	double commission=0.0;
    
    	
    		if(amount<=10000){
    			
    			commission = amount*0.1;
    			}
    
    			else if(amount<30000.01){
    				
    				commission=10000*0.1+(amount-10000)*0.15;
    				}
    				else {
    					commission=10000*0.1+20000*0.15+(amount-30000)*0.2;
    				}
    		 	//to round the commission gained:
    			
    			commission=Math.round(commission *100)/100;
    			
    			//output/return the commission
    		
    			return commission;
    			        
    			}
    			
    	
    }

Similar Threads

  1. Replies: 4
    Last Post: 11-21-2012, 01:19 PM
  2. Replies: 2
    Last Post: 04-02-2011, 12:57 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
  •