please check my code
here goes the problem:
A bicycle salesperson is offered a choice of wage plans:
1) straight salary of $300
2)$3.50 per hour for 40 hrs plus 10% commission on sales
3)a straight 15% commission on sales with no other salary.
Write a program that takes as input the salesperson's expected weekly sales and outputs the wages paid under each plan in increasing order.
import java.util.*;
publicclass Number18
{
publicstaticvoid main(String[] args)
{
double Wage1,d2,d3,Wage3,Wage2;
Scanner s=new Scanner(System.in);
System.out.println("Enter Your Estimated Weekly Sales:");
double dSales=s.nextFloat();
d2=3.50*40 + dSales*.10;
d3=dSales*.15;
Wage1=Math.min(d2,d3);
Wage3=Math.max(d2,d3);
Wage2=Wage3-Wage1;
if (Wage1>300)
System.out.println("Wage 1 is:" +"$300");
else
System.out.println("Wage 1 is:" +"$" + Wage1);
if (Wage2>300 && Wage1<Wage2)
System.out.println("Wage 2 is:" +"$300");
else
System.out.println("Wage 2 is:" +"$" + Wage2);
if (Wage3>300)
System.out.println("Wage 3 is:" +"$" + Wage3);
else
System.out.println("Wage 3 is:" +"$300");
s.close();
}
}
did i do it correctly? THANK YOU!!
Message was edited by:
pink-fire
[2304 byte] By [
pink-firea] at [2007-11-27 11:17:45]

Here's your output and mine for an input of $2500
Enter Your Estimated Weekly Sales:
2500
Wage 1 is:$300
Wage 2 is:$15.0
Wage 3 is:$390.0
Straight Salary: $300.00
Commission Only: $375.00
Salary and Commission: $390.00
ps: I did this program by trying out the Strategy Pattern for the first time. I had to see if I could do it, and it was cool as heck to do, though my code is probably a bit sloppy. I may show it here, because there is no way that the OP could use my code and turn it in as his own without raising suspicions
Message was edited by:
petes1234
But, for the OP's education, I might start with an interface like this:
package cruft.salary;
/**
* SalaryCalculator
* User: Michael
* Date: Jul 21, 2007
* Time: 1:09:19 PM
*/
public interface SalaryCalculator
{
double calculateSalary(double timeWorked, double sales);
}
Have separate implementations for each of the cases.
%
> Yep, agree that a little interface to tie all of the
> OP's classes together would be nice. But I doubt
> s/he's even hit OOP or classes yet given the looks of
> his/her code.
So tell me why you suggested a strategy pattern? Was it a chance for you to announce to the world that you've heard of the GoF?
%
> So tell me why you suggested a strategy pattern? Was
> it a chance for you to announce to the world that
> you've heard of the GoF?
>
> %
It was not for the OP's benefit. I was just being a smart-A**. Probably a dumb thing to do, but I'm kind of Pattern-crazy right now, as I am delving into a pattern book (no, not the GoF; mine is more light-weight -- Head First). So I'm seeing patterns everywhere.