Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

I need help, my java program is returning nothing when i compile it

By: a guest on Mar 23rd, 2012  |  syntax: None  |  size: 5.36 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class Employee
  2. {
  3.     String name;             // Employee name
  4.     String employeeNumber;   // Employee number
  5.     String hireDate;         // Employee hire date
  6.     int shift;                   // Employee shift
  7.     double payRate;
  8.  
  9.     public void setEmployeeNumber(String e)
  10.     {
  11.        if (isValidEmpNum(e))
  12.        {
  13.           employeeNumber = e;
  14.        }
  15.        else
  16.        {
  17.           employeeNumber = "";
  18.        }
  19.     }
  20.  
  21.     public Employee(String name, String e, String hireDate, double payRate, int shift)
  22.     {
  23.        this.name = name;
  24.        this.setEmployeeNumber(e);
  25.        this.hireDate = hireDate;
  26.        this.payRate = payRate;
  27.        this.shift = shift;
  28.     }
  29.  
  30.     public Employee()
  31.     {
  32.        name = "";
  33.        employeeNumber = "";
  34.        hireDate = "";
  35.     }
  36.  
  37.     public void setpayRate(double payRate)
  38.     {
  39.        this.payRate = payRate;
  40.     }
  41.  
  42.     public double getpayRate()
  43.     {
  44.        return payRate;
  45.     }
  46.  
  47.     public void setshift(int shift)
  48.     {
  49.        this.shift = shift;
  50.     }
  51.  
  52.     public int getshift()
  53.     {
  54.        return shift;
  55.     }
  56.  
  57.  
  58.     public void setName(String name)
  59.     {
  60.        this.name = name;
  61.     }
  62.  
  63.     public void setHireDate(String hireDate)
  64.     {
  65.        this.hireDate = hireDate;
  66.     }
  67.  
  68.         public String getName()
  69.     {
  70.        return name;
  71.     }
  72.  
  73.     public String getEmployeeNumber()
  74.     {
  75.        return employeeNumber;
  76.     }
  77.  
  78.     public String getHireDate()
  79.     {
  80.        return hireDate;
  81.     }
  82.  
  83.     private boolean isValidEmpNum(String e)
  84.     {
  85.        boolean status = true;
  86.  
  87.        if (e.length() != 5)
  88.           status = false;
  89.        else
  90.        {
  91.          if ((!Character.isDigit(e.charAt(0)))  ||
  92.             (!Character.isDigit(e.charAt(1)))   ||
  93.             (!Character.isDigit(e.charAt(2)))   ||
  94.             (e.charAt(3) != '-')                ||
  95.             (!Character.isLetter(e.charAt(4)))  ||
  96.             (!(e.charAt(4)>= 'A' && e.charAt(4)<= 'M')))
  97.           {
  98.              status = false;
  99.           }
  100.        }
  101.        return status;
  102.     }
  103.     public String toString()
  104.     {
  105.        String str = "Name: " + name + "nEmployee Number: ";
  106.  
  107.        if (employeeNumber == "")
  108.        {
  109.           str += "INVALID EMPLOYEE NUMBER";
  110.        }
  111.        else
  112.        {
  113.           str += employeeNumber;
  114.        }
  115.  
  116.        str += ("nHire Date: " + hireDate);
  117.        return str;
  118.     }  
  119. }
  120.        
  121. import javax.swing.JOptionPane;
  122.  
  123. public class ProductionWorkerDemo extends Employee
  124. {
  125.     public static void main(String[] args)
  126.     {
  127.        String name;             // Employee name
  128.        String employeeNumber;   // Employee number
  129.        String hireDate;         // Employee hire date
  130.        int shift;                    // Employee shift
  131.        double payRate;               // Employee pay
  132.        String str;
  133.        String str2;
  134.  
  135.  
  136.        name = JOptionPane.showInputDialog("Enter your name: ");
  137.  
  138.        employeeNumber = JOptionPane.showInputDialog("Enter your employee number: ");
  139.  
  140.        hireDate = JOptionPane.showInputDialog("Enter your hire date: ");
  141.  
  142.        str = JOptionPane.showInputDialog("Enter your shift: ");
  143.  
  144.        payRate = Double.parseDouble(str);
  145.  
  146.        str2 = JOptionPane.showInputDialog("Enter your payrate: ");
  147.  
  148.        payRate = Double.parseDouble(str2);
  149.  
  150.        ProductionWorkerDemo pw = new ProductionWorkerDemo();
  151.  
  152.         System.out.println();
  153.         System.out.println("Name: " + pw.getName());
  154.         System.out.println("Employee Number: " + pw.getEmployeeNumber());
  155.         System.out.println("Hire Date: " + pw.getHireDate());
  156.         System.out.println("Pay Rate: " + pw.getpayRate());
  157.         System.out.println("Shift: " + pw.getshift());
  158.  
  159.     }
  160. }
  161.        
  162. import javax.swing.JOptionPane;
  163.  
  164. public class ProductionWorkerDemo
  165. {
  166.     public static void main(String[] args)
  167.     {
  168.        String name;             // Employee name
  169.        String employeeNumber;   // Employee number
  170.        String hireDate;         // Employee hire date
  171.        int shift;                    // Employee shift
  172.        double payRate;               // Employee pay
  173.        String str;
  174.        String str2;
  175.  
  176.  
  177.        name = JOptionPane.showInputDialog("Enter your name: ");
  178.  
  179.        employeeNumber = JOptionPane.showInputDialog("Enter your employee number: ");
  180.  
  181.        hireDate = JOptionPane.showInputDialog("Enter your hire date: ");
  182.  
  183.        str = JOptionPane.showInputDialog("Enter your shift: ");
  184.  
  185.        payRate = Double.parseDouble(str);
  186.  
  187.        str2 = JOptionPane.showInputDialog("Enter your payrate: ");
  188.  
  189.        payRate = Double.parseDouble(str2);
  190.  
  191.        Employee pw = new Employee(/*provide arguments here*/);
  192.  
  193.         System.out.println();
  194.         System.out.println("Name: " + pw.getName());
  195.         System.out.println("Employee Number: " + pw.getEmployeeNumber());
  196.         System.out.println("Hire Date: " + pw.getHireDate());
  197.         System.out.println("Pay Rate: " + pw.getpayRate());
  198.         System.out.println("Shift: " + pw.getshift());
  199.  
  200.     }
  201. }
  202.        
  203. public class ProductionWorkerDemo extends Employee{
  204.  
  205.   public ProductionWorkerDemo(String name, String e, String hireDate, double payRate, nt shift){
  206.  {
  207.      super(name, e, hireDate, payRate, shift);
  208.   }
  209.  
  210. }
  211.        
  212. ProductionWorkerDemo pw = new ProductionWorkerDemo(name,
  213.                                     employeeNumber,
  214.                                     hireDate,
  215.                                     payRate,
  216.                                     shift);
  217.        
  218. ProductionWorkerDemo pw = new ProductionWorkerDemo(name,employeeNumber,hireDate,payRate,shift);