Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Program to compute commission using two methods

Mon Mar 30, 2009 11:04 pm

Program to compute commission using two overloaded methods
I've been assigned a project. I am to compute Commission by using two overloaded methods. I have to create a class named Commission that includes 3 variables:double sales figure, a double commission rate, and an integer commission rate. Create two overloaded methods named computeCommission().
The first method takes two double arguments representing sales and rate, multiplies them, and then displays the results. The second method takes two arguments: a double sales figure and an integer commission rate. It must divide the commission rate figure by 100.0 before multiplying by the sales figure and displaying the commission. Supply appropriate values for the variables, and write a main() method that tests each overloaded method. Okay, that's the assignment! Following is the coding that I did. Where did I go wrong because when I execute this (java Commission).....I get NOTHING.

Code:

public class Commission
{
    public static void main(String[] args)
    {
        double salesFig = 4000.00;
        double commRate = 0.075;
        int commRateFig = 7;
        computeCommission ();
    }
    public static void computeCommission(double salesFig, double commRate)
    {
        double commission;
        commission = commRate * salesFig;
        System.out.println("The commission on $" + salesFig + "is $" + commission);
    }
    public static void computeCommission(double salesFig, int commRateFig)
    {
        double commission;
        commission = commRateFig / 100.0 * salesFig;
        System.out.println("The commission on $" + salesFig + "at  %" + commRateFig + "is 

$"
 + commission);
    }
}
 




Re: help with this assignment

Thu Apr 09, 2009 7:17 pm

Code:
double commission;
commission = commRateFig / 100.0 * salesFig;
System.out.println("The commission on $" + salesFig + "at %" + commRateFig + "is


Post a reply
  Related Posts  to : Program to compute commission using two methods
 errors in commission program     -  
 compute area of the circle.     -  
 compute binomial coefficients     -  
 Compute FFT (Fourier Transform) in ITK for a 2d image     -  
 loop to compute the tuition in ten years     -  
 compute number of files in directory     -  
 compute maximum and minimum values, also scaling factor.     -  
 Which methods is best for SEO?     -  
 What Are Constructor Methods?     -  
 Calling Overloaded Methods     -