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


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: Calling Overloaded Methods
PostPosted: Thu Nov 03, 2011 6:35 pm 

I can't seem to get any of the methods to call.

Problem Part a: Create a class named Commission that includes three variables: a double sales figure, a double commission rate, and an int commission rate. Also create two overloaded methods named computeCommission(). The first method takes two double parameters from the user representing sales and rate, multiplies them, and then displays the results. The second method takes two parameters from the user: a double sales figure and an integer commission rate. This method must divide the commission rate figure by 100.0 before multiplying by the sales figure and displaying the commission. Write a main() method that tests each overloaded method. Save the file as Commission.java

Part b: Add a third overloaded method to the Commission application. The third parameter takes a single parameter representing sales. When the method is called, the commission rate is assumed to be 7.5% and the results are displayed . To test this method , add an appropriate call in the commission program's main () method . Save the file as Commission2.java

I wrote the code and the program doesn't return any errors, but for some reason the program only calls one of three methods. For example, if the user enters $4387.69 for their sales amount and then enters .27 for their commission rate the program will calculate their commission earnings to be $1184.6763, but if the user were to have entered 27 for the commission rate instead if the program calling the appropriate function to convert the that number it runs the same function again.

Can someone please tell me what I'm doing wrong? Here is my code Thanks!
________________________________________________________________

import java.util.Scanner;
public class Commission {

public static void main(String[] args){
Commission cs=new Commission();
// method 1 = 2 parameters = double, double
cs.computeCommission(0.0-100000.0,.00-.100);
// method 2 = 2 parameters = double, integer
cs.computeCommission(0.0-100000.0,(0-100)/100);
//method 3 = 1 parameter = double
cs.computeCommission(100000.1-1000000);

}

//creating method 1
void computeCommission (double rate, double salesFigure)
{
Scanner input = new Scanner(System.in);
System.out.println(" Enter your total sales amount ");
salesFigure = input.nextDouble();
System.out.println(" Enter your commission rate ");
rate = input.nextDouble();
double computeCommission;
computeCommission = salesFigure * rate;
System.out.println(" Your commission is $ " + computeCommission);

}

//creating method 2
void computeCommission ( double salesFigure2,int commissionRate)

{
Scanner input = new Scanner(System.in);
System.out.println(" Enter your total sales amount ");
salesFigure2 = input.nextDouble();
System.out.println(" Enter your commission rate ");
commissionRate= input.nextInt();
double computeCommission;
computeCommission = salesFigure2 * ( commissionRate/ 100);
System.out.println(" Your commission is $ " + computeCommission);

}

//creating method 3
void computeCommission (double salesFigure3)
{

Scanner input = new Scanner(System.in);
System.out.println(" Enter your total sales amount ");
salesFigure3 = input.nextDouble() * .075;
System.out.println(" Your commission is $ " + salesFigure3);

}







}


TOP
  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 Which methods is best for SEO?
 methods with variable arguments list
 calling method to form- displaying textbox data in messagbox
 CME display calling number without leading 0
 signature creating in easy methods
 Static Methods and Variables
 Calling a Private Method in jsp
 JSP Passing Arrays to Methods
 Explain the life cycle methods of a Servlet.
 purpose of the wait(), notify(), and notifyAll() methods

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: Google Adsense [Bot] and 2 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