Methods, Classes, and Objects

Hello I have to create a program that calculates a
salesperson’s commissions using double-precision values,
and displays the results. The commission rate in the first
method will be entered as a decimal value (for example, a
7.5% rate will be entered as 0.075).
A second method will be included that takes the same sales
value as the first method, but has the commission rate
entered as an integer (for example, 7 would be entered
for 7%.). This commission value is then divided by 100.0,
the sales figure is multiplied by the result of that calculation,
and the final result is displayed to the user.
These two methods will be saved as Commission.java, and
compiled as Commission.class.
Finally, you’ll add a third method to the previous program. This
method will use the same sales value as the previous methods,
but will calculate the commission based on afixed 7.5% rate.
The completed program with all three methods shall be saved
as Commission2.java and compiled as Commission2.class.

My attached file is what I have so far. I really want to understand java. Please help Commission.java
lovemycomputersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

for_yanCommented:
But why did not you write all these methods in your code?

If this is a hoemowork - we cannot write program instaed of you - we can only
correct your code.
The snippet you posted has no methods, which you mentioned.

Attempt to write them and then we can look at them togeteher
0
lovemycomputersAuthor Commented:
No I want  someone to help me learn how to write programs on my own. Don't do it for me , I just need guidance on how to successfully do this.
0
for_yanCommented:
so write these methods so that I could correct.
I can write the first lines for you:

public double getCommission(double sales, double commissionRate) {....}

public double getCommission(double sales, int commissionRateInPercents) {....}

public double getCommission(double sales) {...}

now write the bodies of the methods and put them in the class

0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

lovemycomputersAuthor Commented:
Ok I think this is alot closer but with the rate it's hard. I can't seem to get the calculations to perform correctly.

public class Commission
{
      public static void main(String[] args);
      {
      double sales = 50000;
      double commRate = 0.075;
      int rate = 7; }
      
      {
      public double computeCommission double sales, double commRate;
      commission = sales * commRate;
      System.out.println("Commission on " + sales + "sales figure with" + commRate + "%" + "is " + commission); }
      
      {
   public double computeCommission double sales, int rate;
      commission = rate/100.0;
      commission = rate * sales;
      System.out.println(""); }
      
}
0
for_yanCommented:
No, these don't even follow any formats of the methdos
- how shouel method be declared, where should methdo parameters be placved?
How should you separate methiod declaration from methoed body

Look at any example of any java code and make ity right
0
lovemycomputersAuthor Commented:
I'm sorry i think this is the simplier way:

public double computeCommission double sales, int rate;
      commission = (rate/100.0 * sales);
      System.out.println(""); }
0
for_yanCommented:
no, no,  this syntax is wrong

read the beginning of very basic java book
or find on-line java beginner tutorial (juast paste this to google)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lovemycomputersAuthor Commented:
This is what I have now but I'm going to read this beginners book I found so that way I can try to learn it on my own because its too difficult for me and I want to learn it without help. So thanks alot for attempting to help me. I greatly appreciate it :)

public class Commission
{

      public static void main(String[] args);
      {
      double sales = 50000;
      double commRate = 0.075;
      int rate = 7; }
      
      public double computeCommission (double sales, double commRate)
      {
      commission = sales * commRate;
      System.out.println("Commission on " + sales + "sales figure with" + commRate + "%" + "is " + commission); }
      
   public double computeCommission (double sales, int rate)
      {
      commission = (rate/100.0 * sales);
      System.out.println(commission); }
      
      public static void computeCommission (double sales)
      {
      commission = (sales * (int) rate);
      System.println("The commission of" + sales + "with a" + rate + "is" + commission);
      }
}
}
 
0
for_yanCommented:

Method which decalres return type should return value
these methods would never compile
0
lovemycomputersAuthor Commented:
Ok
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.