Results 1 to 3 of 3

Thread: Help!

  1. #1
    slynnie90 is offline Member
    Join Date
    Mar 2012
    Posts
    1
    Rep Power
    0

    Default Help!

    I am very new to java and I cannot figure out where I have gone wrong. This is for a class assignment, so any help would be great! Thanks!

    First Class:

    public class SalesPerson {
    String name;
    double decemberSales;
    double januarySales;
    double baseSalery;
    String title;

    public class SalesPersonClass {
    private String name;
    private double decemberSales;
    private double januarySales;
    private double baseSalery;
    private String title;

    public SalesPersonClass(String newName, double newDecemberSales,
    double newJanuarySales, double newBaseSalery, String newTitle) {
    name = newName;
    decemberSales = newDecemberSales;
    januarySales = newJanuarySales;
    baseSalery = newBaseSalery;
    title = newTitle;
    }

    public SalesPersonClass(String newName) {
    name = newName;
    decemberSales = 0;
    januarySales = 0;
    baseSalery = 10000;
    title = "unknown";
    }

    }

    public String getName() {
    return name;
    }

    public double getDecemberSales() {
    return decemberSales;
    }

    public double getJanuarySales() {
    return januarySales;
    }

    public double getBaseSalery() {
    return baseSalery;
    }

    public String getTitle() {
    return title;
    }

    public void setdecemberSales(double newDecemberSales) {
    if (newDecemberSales >= 0) {
    decemberSales = newDecemberSales;
    } else {
    System.out.print("Please Enter a Valid Amount");
    }
    }

    public void setJanuarySales(double newJanuarySales) {
    if (newJanuarySales >= 0) {
    januarySales = newJanuarySales;
    } else {
    System.out.print("Please Enter a Valid Amount");
    }
    public void setBaseSalery(double newBaseSalery) {
    baseSalery = newBaseSalery;
    }

    double totalSales = januarySales + decemberSales;
    if(januarySales>decemberSales){
    return januarySales;
    }else{
    return decemberSales;

    }
    double salesBonus;
    if (totalSales < 40000){
    salesBonus = totalSales + (totalSales*.02);
    //do not know how to enter between 40,000 and 50,000
    }else if( totalSales < 50000){
    salesBonus = totalSales + (totalSales*.03);
    }else if(totalSales >50000){
    salesBonus = totalSales + (totalSales*.05);
    }
    double titleBonus;
    if (title = "Manager"){
    titleBonus = 2500;

    double totalEarned = totalSales + salesBonus + titleBonus;

    }
    System.out.print("Name: " + name);
    System.out.print("Title: "+ title);
    System.out.print("December Sales: "+ decemberSales);
    System.out.print("January Sales: " + januarySales);
    System.out.print("Total Sales: "+ totalSales);
    System.out.print("Total Earned: "+ totalEarned);


    }
    }
    Second Class:

    public class SalesPerson {

    public static void main(String[] args) {
    SalesPerson firstPerson = new SalesPerson("Lucy", 35000.00, 75000.65,
    23000.00, "Vice President");
    SalesPerson secondPerson = new SalesPerson("Tom", 12000.00, 3000,
    10000.00, "Manager");

    SalesPerson thirdPerson;
    System.out.print("Please Enter a name:");
    SalesPerson.setName();

    System.out.print("Please Enter December Sales");
    SalesPerson.setDecemberSales();

    System.out.print("Please Enter Your Title");
    SalesPerson.SetTitle();

    januarySales = 23456.78;

    I'm getting confused as to how to change the parameters in the second class using the first class, if that makes sense.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Help!

    Quote Originally Posted by slynnie90 View Post
    I am very new to java and I cannot figure out where I have gone wrong. This is for a class assignment, so any help would be great! Thanks!
    Consider *telling* us how it's not working. Just what your class does or doesn't do or exactly where you're stuck.

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default Re: Help!

    When posting code, please use the code tags to preserve formatting.

    Recommended reading: Passing Information to a Method or a Constructor (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •