Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners java inheritance
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


john high
java inheritance
0 Answer(s)      11 months ago
Posted in : Java Beginners


ACME Bike shop has created a new scheme to reward employees for selling bicycles. Sales are only made by either, a sales person on the shop floor or by a sales agent, both of whom are considered employees. Commission on the sale of each bicycle is to be paid to sales persons at a rate of 15% and to the sales agents at a rate of 10%. Write a Java application that calculates and displays the commission to be paid to each employee, the employees name, their PPS number and the total value of the sale. The application should contain three classes, a SalesEmployee class, a SalesPerson class and a SalesAgent class. You are required to ensure that the application only allows for two types of sales employees, a sales person and a sales agent. You should also create a tester class to illustrate to workings of the application.

I am really confused and a have spent a long time on it. i just cannot figure how to call back my calculations and also the names and PPS number. I know it a assignment but any help would be good?

public abstract class employees {

protected  double  sales;
protected static   String   name;
protected static int      ppsnumber;
protected static int num_of_bikes;



public employees(String newname, int newsales, int newpps,int newnumofbikes)  {
    name = newname;
   sales = newsales ;
    ppsnumber = newpps;
    num_of_bikes = newnumofbikes;
}

public employees() {
    this( "Not Given");

}
public employees(String string) {

}

public String getname(){
    return name;
}
public double getsales(){
    return sales;
}
public int getppsnumber(){
    return ppsnumber;
}
public double getnumofbikes(){
    return num_of_bikes;

}
public void setnumofbikes(int newnumofbikes){
    num_of_bikes =newnumofbikes;   

}
public void setName(String newName) {
    name = newName;
}

  public void setppsnumber (int ppsnumber) {
     ppsnumber = getppsnumber();
  }
  public int setsales(int newsales) {
     return newsales * num_of_bikes;


     }
  public abstract void computetotalsales( );

}

public class sales_agent extends employees {

    public double totalsale;
    public String tostring;


    public sales_agent(String name, double ppsnumnber){
        super();
        totalsale = sales;

    }

         public double gettotalsale(){
             return totalsale = sales * 0.10 + num_of_bikes;



         }


        public void computetotalsales() {


        }




        }

public class sales_person extends employees {

    public double totalsale;
    public String tostring;


    public sales_person(String name, double ppsnumnber){
        super();
        totalsale = sales;

    }

         public double gettotalsale(){
             return totalsale = sales * 0.10 + num_of_bikes;



         }


        public void computetotalsales() {


        }

        }

import java.util.ArrayList; import java.util.Scanner;

import javax.swing.JOptionPane;

public abstract class tester_class extends employees { public tester_class() { } public static void main(String [] args) {

    ArrayList<employees> es =new ArrayList<employees>();


    sales_person sp = new sales_person ("john", 33444);

    es.add(sp);

    sales_agent sa = new sales_agent("adrian", 44444);
    es.add(sa);




    sa.gettotalsale();


    sp.gettotalsale();



    JOptionPane.showMessageDialog(null, " Name of sales person is: "+ sp.getname() + "\n ppsnumber is"
    + sp.getppsnumber() + "\n number of bikes sold " + sp.getnumofbikes() + "\n total are " + sp.getsales());

    JOptionPane.showMessageDialog(null, " Name of sales agent is: "+ sa.getname() + "\n ppsnumber is"
            + sa.getppsnumber() + "\n number of bikes sold " + sa.getnumofbikes() + "\n total are " +  sa.gettotalsale());

    JOptionPane.showMessageDialog(null, "Commission is " +sa.gettotalsale());
}

}strong text

Blockquote


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Inheritance,Inheritance in Java,Java Inheritance
kinds of inheritance are there in java.   Simple Inheritance  .... Java does not support multiple inheritance but the multiple inheritance can be achieved by using the interface. In Java Multiple Inheritance can be achieved
Java inheritance
Java inheritance   can the child access protected content of the parent if the child is in a different project   If you have considered different project as different package then the child cannot access the content
Advertisements
java inheritance
java inheritance  problem with following code.... class Employee { int empno; String name; String edesig; Employee() { empno=0; } Employee(int eno,String ename,String ed) { empno=eno; name=ename
java inheritance
java inheritance  ACME Bike shop has created a new scheme to reward employees for selling bicycles. Sales are only made by either, a sales person...% and to the sales agents at a rate of 10%. Write a Java application
Inheritance in java - Java Beginners
Inheritance in java  I want a example program using the concept of (single and multiple) inheritance.  Hi Friend, Please visit the following link: http://www.roseindia.net/java/language/inheritance.shtml Thanks
inheritance - Java Beginners
inheritance  help me on inheritance concept in java specialy on overloading and overridding concept
Concept of Inheritance in Java
Concept of Inheritance in Java Concept of Inheritance in Java is considered... class from parent class. Let's understand the concept of inheritance in Java... that is used for reusability purpose. There are three types of inheritance in java
Inheritance in java - Java Beginners
Inheritance in java  I want a example program using the concept of (simple and multiple) inheritance
inheritance
inheritance  how does one implement inheritance in java
multiple inheritance - Java Beginners
multiple inheritance  Why java does not support Multiple Inheritance...)why java classes does not support Multiple Inheritance? JAVA CLASSES ONLY... Inheritance. Ans...>java classes doesn't support multiple inheritance,the practical
how can i achieve multiple inheritance in java without using inheritance ?
how can i achieve multiple inheritance in java without using inheritance ?  how can i achieve multiple inheritance in java without using inheritance
Java Inheritance Concept.
Java Inheritance Concept.  Yesterday i got confused with following question in an aptitude exam. Question:Class A,B,C have method named doit(). Class B extends Class A,Class C extends Class B.How will you call method doit
Inheritance java Example
Inheritance java Example  How can we use inheritance in java program?   class Animal { public void eat(String str... of inheritance. Inheritance is a way of establishing a subtype from an existing object
Inheritance and Composition - Java Beginners
inheritance class TextDemo { int x; int y; int get(int p, int q...Inheritance and Composition  import java.util.*; public class... arrangement in the design of your solution. In an object-oriented design of a Java
Inheritance Overloading - Java Beginners
Inheritance Overloading  The problem is: I have this program: class Base{ int i = 1; int j = 2; Base(int i, int j){ i = i; j = j...://www.roseindia.net/java/beginners/constructoroverloading.shtml
Java Inheritance - Java Beginners
Java Inheritance  Since every object inherits from Object class, why the following statement is not true. Assuming the code tries to open a file then instead of using throws IOException why not use throws Object? import
Inheritance - Java Beginners
Inheritance  pls help me!!! Question: write an inheritance hierachy for classes Quadrilateral,Trapezoid,Parallelogram, Rectangle and Square. Use Quadrilateral as superclass. make hierachy as deep as possible. Specify
Inheritance - Java Beginners
of Inheritance within the java programming. class Points{ private double x... and set the center of thye base. THANKS SO MUCH. I am really a java beginner
Inheritance Example In Java
Inheritance Example In Java In this section we will read about the Inheritance... the Inheritance in Java the Multiple inheritance is not supported. This reduces... the inheritance feature in Java programming. This example will demonstrate you
Does Java support multiple inheritance?
Does Java support multiple inheritance?  Hi, Does Java support multiple inheritance? thanks   hi, Please visit the following link: http://www.roseindia.net/java/language/inheritance.shtml Hope
Java code to implement MULTIPATH INHERITANCE
Java code to implement MULTIPATH INHERITANCE  HI, I am new to java programming. I want to implement multipath inheritance in one java program...(Hierarchical and Multiple inheritance) Thanks in advance
Inheritance and Composition - Java Beginners
Inheritance and Composition  import java.util.*; public class TestPet { public static void main(String[]kevs) { Scanner console=new Scanner(System.in); String type, name, home; int weight, years; char gender
Inheritance problem - Java Beginners
Inheritance problem  hello friend can u please help me that why this program is printing show method of Base_Class b=5 even though i am assigning the Base_Class object into the Super_Class reference i.e Super_Class bc=new
Inheritance and Composition - Java Beginners
Inheritance and Composition  CAN YOU FIND THE ERROR OF MY CODE JAVA.THIS IS A TEST CLASS.I CANT FIND THE ERROR,CAN YOU FIX IT FRIEND.THANK YOU SO MUCH. import java.util.*; public class TestPet { public static void main
Inheritance and Composition - Java Beginners
Inheritance and Composition  HELLO FRIEND THIS IS THE CODE,CAN YOU FIND WHAT IS THE ERROR AND IF ITS OK CAN YOU FIX IT .THANK YOU. public class Pet extends Animal { private String home, bite; //private Boolean bites
inheritance
inheritance  hi.. pleaseeeeee i need a quick help(answer) in creating aprogrm in java by using inheritance for car in such away that .... Car is parent class and both of Private and Public Car extends it then both of Bus
Inheritance and Composition - Java Beginners
Inheritance and Composition  HELLO FRIEND THIS IS THE CODE,CAN YOU FIND WHAT IS THE ERROR AND IF ITS OK CAN YOU FIX IT .THANK YOU.10000X THANK YOU.HOPE YOU HELP ME. public class Animal { private int lifeExpectancy, weight
Inheritance and Composition - Java Beginners
Inheritance and Composition  HELLO FRIEND THIS IS THE CODE,CAN YOU FIND WHAT IS THE ERROR AND IF ITS OK CAN YOU FIX IT .THANK YOU. THANK YOU.HOPE YOU HELP ME.i think theres one error can u fix the error friend .thank u public
Java code to implement MULTIPATH INHERITANCE
Java code to implement MULTIPATH INHERITANCE  Hi, I am new to java .so please write code for this inheritance example... Student | ----------- | | Test Sports
Multilevel inheritance - Java Beginners
Multilevel inheritance  Dear Sir, I'm posting you another question for which I need a more explanatory java coding(A lengthy one with more classes if possible) "Write a java program to create simple student object and inherit
JAVA CLASS INHERITANCE
JAVA CLASS INHERITANCE  Someone please help me write this program. Create a class called Accounts that has the following members: i)An instance integer variable called acc_no. ii) An instance string variable called acc_name. ii
 

 

 

DMCA.com