Program That Displays Information For Employee Objects Of Different Types

Apr 29, 2014

I'm making a program that displays information for "employee" objects of different types. This works with a hierarchy that goes Person→ Employee→ Fulltime/Adjunct, and a driver that tests the inheritance. The Person class is given and only supplies the name, the employee class manages the year hired and the ID, and the types of employee classes manage the salaries.

One object (called staff[2]) is supposed to first be printed with default information and then later updated via set methods. I figured out how to update the name, but I don't know how to update the rest of the information because the employee's name is managed in the Person class and the reset of the information is managed in the less-general classes, and the objects are all in an array of Person.

How do I call the set methods necessary to update more of staff[2]?Output (scroll to see the updating section)

The current year is 2012

Name: Flintstone, Fred
ID Num: BR-1
Year Hired: 2005
Years Of Service: 7
Salary: 65000.12
Fulltime Type Employee

[code]....

View Replies


ADVERTISEMENT

Write A Java Program To Store Employee Information In A Linked List

May 12, 2015

Write a java program to store employee information in a linked list, the program should implement the following functions:

The program should display the list of functions, and ask the user to enter the number of function that he/she wants to do, then perform the function as it is required in the previous table.

import java.util.*;
public class Employee {
Scanner in = new Scanner(System.in);
String Name;
String Address;
String Department;
int ID;
int Salary;

[code]....

this is my out put

Please choose a number:
1-Add a new employee
2-Update employee's info
3-Remove employee's info
4-Exit
1
Enter name:
Enter address:
2
Enter department:
3
Enter ID:
4
Enter salary:

now:

1- why are not my adding coming out in the output only the Enter name & Enter address ??

2- how can I add names and ID's and information to test that program

View Replies View Related

Adding A Phone Object Into Student / Employee Objects

Jun 1, 2014

I have to read in a file that that has Student, Employee, Faculty....such as name, last name, salary...etc

Example of a file input
Java Code: Student, John, Doe, [email]johnDoe[At]yahoo.com[/email], 123,Wonderland Ave, 21323,TX
PhoneNumber,Cell,111,222,3333
Student, Jesus,Satan,[email]jesus[At]satan.com[/email,666, HeavenHell Dr., 666666,CA
PhoneNumber,Work,111,333,5555 mh_sh_highlight_all('java'); Java Code: while(input.hasNext()){

[code]...

There is more code, but it's repetitive. Now, I keep getting an error. Array of bounds. I believe i get the error because the phone number. The phone number is on the next line..I created a different arraylist for phonenumber, but I dont know how to match it with the correct person, student, employee...etc.

View Replies View Related

Create Class Employee Which Contains A String Variable Employee Number

Jul 13, 2014

I have searched for totalPay is always 0 and the responses are not related to my problem (that I can tell).This is a class assignment and I have other questions besides why the method is not working.

Here are the instructions: Create class Employee which contains a String variable Employee Number, a String variable Employee Name, an integer Hours Worked, and a double Pay Rate. Create get and set methods for each variable. Provide method "totalPay" which calculates and returns the total pay by multiplying the hours worked by pay rate. Use figure 8.12 as an example of an object with get and set methods.

Unlike other examples of this type question online this one has Employee Number as a String variable. The book is How to Program Early Objects by Deitel 9th edition.We have instructions to do only what she has told us too. At this point it is objects and getter and setter methods. It is only the beginning of week 2.

ON THE LINES WHERE I HAVE QUESTIONS I AM COMMENTING IN ALL CAPS. NOT SHOUTING, JUST TRYING TO MAKE IT EASIER

package test11;
import java.util.Scanner;
public class Test11 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

[code]..

Essentially I cannot figure out how to get the method getTotalPay to be called by the Scanner and do the math. I also have this random bracket problem that showed up about an hour ago.

The concept I don't get is that if I omit this.employeeNumber =id; etc. I error all over the place. If I change it to this.employeeeNumber = employee Number Netbeans tells me it is assigning itself to itself, which I know. When I try to use id instead of employeeNumber I get errors all over. If i remove "this" from it the same happens. why in public class employee I have to change to those values (id, name, etc) in the construct and set them again? I don't see where or how they can be used, so why do i have to do it?

View Replies View Related

Contact Information - How To Utilize Objects

Jun 14, 2014

I'm trying to create contact information as object and another object as parcel then calculate the shipping fee. Problem is I don't have a good understanding in implementing object type to my code. Attached are what I've done and I know that my constructor in my parcel class and contact class are probably wrong too but I don't know what to do with it.

//contact class
public class Contact {
private String Name;
private String Address;
private String City;
private String State;
private double Xco;
private double Yco;

[Code] .....

View Replies View Related

Understanding Classes And Objects In Terms Of Data Types

May 8, 2015

I have seen many ways of describing what objects are, one being that objects are a user-defined datatype. However, if objects are datatypes, then what does that make classes? To me, it seems as though classes should be the "types" of data defined by the programmer, and objects should be the specific "values" of that user defined data type. As an example, an integer would be a class, while 1 would be a "value" of that class, i.e. an object. From this point of view, I don't see why a specific number would be a data type... Therefore, why do we say that objects are user defined data types rather than classes?

View Replies View Related

Basic Console Java Program - Generate Employee ID

Feb 27, 2014

Basic console java program. I need to generate an employee id. I have an employee class that I will paste here so you can see my fields and constructors.

public class Employee {
private String firstName;
private String lastName;
private int id;
public int nextUniqueId = 0;
public Scanner sc = new Scanner(System.in);

[Code] ....

View Replies View Related

Program That Displays First 100 Pentagonal Numbers Using Different Methods

Feb 28, 2015

I have to write a program that displays the first 100 pentagonal numbers using different methods. This is what I have so far:

Java Code:

public class FivePointOne{
public static void main(String[]args){
System.out.println("The the pentagonal numbers are: ");
}
//this method will find the penagonal numbers
public static int getPentagonalNumber(int n){

[Code] ....

But when I compile it to test it out I receive the error message "Illegal start of expression," ';' expected, and "reach end of file while parsing".

View Replies View Related

Load Some Information From Previous Object Files And Add New Objects To Them Afterwards

Dec 17, 2014

I have a project in java that asks me to load some information from previous object files and add new objects to them afterwards. I created the files, but when I close the program and search for the previous information that should've been saved in the object file , it return nothing.

Here is the code.

Add method:

public boolean addUser (User u){
users[Ucount]=u;
Ucount++;
return true;
}

The save method:

public void saveUser (){
try{
FileOutputStream FOS = new FileOutputStream("User.txt", true);
ObjectOutputStream OOS = new ObjectOutputStream (FOS);

[Code] ....

The read method:

public void readUser (){
try{
FileInputStream FIS = new FileInputStream ("User.txt");
ObjectInputStream OIS = new ObjectInputStream (FIS);
for (int i=0;i<Ucount;i++){

[Code] ....

*Note: When I open the object file I could see that the information are actually there, so I think there's a problem with the read method I'm not sure what it is.

View Replies View Related

Program That Displays A Smiley Face Bouncing Around The Screen

May 30, 2014

I am writing a program that displays a smiley face bouncing around the screen. When I load the program it just shows a blank black JFrame. Here is the panel JPanel

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ReboundPanel extends JPanel {
private final int WIDTH = 300, HEIGHT = 100;
private final int DELAY = 20, IMAGE_SIZE= 35;
private ImageIcon image;

[Code]...

I have a suspicion that it might have to do with image = new ImageIcon("happyFace.gif");

I have tried other programs using .gif and they haven't worked on my computer and I haven't been able to figure out why.

View Replies View Related

Test Program That Prompt User To Enter N And Displays N-by-b Matrix

Nov 25, 2014

I did a problem from my book which is "Write a method that displays an n-by-n matrix. Each element is 0 or 1, which is generate randomly. Write a test program that prompts the user to enter n and displays the n-by-b matrix".

So if a user would enter 3, and output could be 0 1 1
0 1 0
1 0 1

So here's my question... I was able to get the program to work in the way my book describes (by just writing the code in the class with the main), but for practice, I want to learn how to do this OOP-style...

I'm not sure how to do this, though, since the method is a void method, so I can't seem to call it within a toString method.

import java.util.Scanner;
public class MatrixTest {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter an int");
int number = input.nextInt();
MatrixClass mc = new MatrixClass(number);

[Code] .....

View Replies View Related

PPS Number Generation - Netbeans Displays (Cannot Find Symbol) And Program Fails To Run

Jan 22, 2015

I am writing a payroll program .The program generates random PPS numbers and then takes in users information and calculates the salary accordingly. I am using netbeans and my code is showing errors on line 18 and 42 ("cannot find symbol")on the code for grossPay(). The program seems to crash after a new PPS number is generated and will not run.

package sd_assg_2;
import java.util.Arrays;
import java.util.Random;
import javax.swing.JOptionPane;
public class SD_ASSG_2 {
  public static void main(String[] args) {
String[] newPPs = getPPSno();

[Code] ....

View Replies View Related

Write A Program That Prompts User To Enter A Password And Displays Valid Password

Dec 3, 2014

My homework is asking me to write a program that prompts the user to enter a password and displays "valid password" if the rule is followed or "invalid password"

Sample
enter a string for password: wewewx
valid password

It's being graded on
Design of my GUI
Dialog box
User friendliness
Creativity

My current issues with the current code I have written is simply the password doesn't work unless it starts with 2 digits, the other order it displays as wrong. and I have no idea how to add a GUI.

import java.util.*;
import java.lang.String;
import java.lang.Character;

[code]....

View Replies View Related

Program That Is To Store DVD Information?

Nov 11, 2014

i have a program that is to store DVD information and when i enter all the information asked it returns no info. I have a DVD inventory file and a DVD extended file.

DVDinventoryprogram class
package inventory2;
import java.util.Scanner;

[Code]....

View Replies View Related

Java Program - Display Up To 5 Pairings Of Data Types

Sep 7, 2014

I need to write a simple program that displays up to 5 pairings of data types (int, string) (string, long) ect. I need to have at least two classes, a Pair class (generic) and an PairTest class.

View Replies View Related

Inventory Program - Display Information To GUI

Feb 28, 2015

I am trying to create a GUI with already existing code. My assignment is: Modify the Inventory Program to use a GUI. The GUI should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the GUI should display the value of the entire inventory, the additional attribute, and the restocking fee.

Where to start. The text book does not cover a GUI that displays this type of information rather it just displays graphics. I would like to create a separate class that holds the GUI information just to make everything flow better. I have provided my current code below:

Java Code:

// ProductTest.java
// by JakeB
public class ProductTest {
// main method begins
public static void main(String[] args) // begin main {
myGUI display = new myGUI();
display.setVisible(true);

[Code] .....

This is all I have for the GUI. I am at a total loss and I am behind 2 weeks now. I cannot move forward until I am able to get this done and the class ends next week.

View Replies View Related

Invoice Program - Convert Strings For Quantity And Price To Numeric Types

Feb 12, 2015

In the test program, you will need to convert the Strings for quantity and price to numeric types. To do this, you could use the Integer.parseInt() method and the Double.parseDouble() methods. I'm not sure what he means by that. I attempted it in my program but I get these errors

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
number cannot be resolved to a variable
description cannot be resolved to a variable
quantity cannot be resolved to a variable
price cannot be resolved to a variable
Duplicate local variable quantity
Duplicate local variable price
Syntax error on token "myInvoice", delete this token
The method getinvoiceAmount() is undefined for the type String

at InvoiceTest.main(InvoiceTest.java:7)

Code:
 
public class Invoice
{
private String number; //Instance variables
private String description;//Instance variables
private int quantity;//Instance variables
private double price;//Instance variables
 
 [Code] .....

View Replies View Related

Create A Program That Keeps Track Of Information Input By User

Sep 17, 2014

I am new to Java an have to Create a program that keeps track of the following information input by the user: First Name, Last Name, Phone Number, and Age. Now - let's store this in a multidimensional array that will hold 10 of these contacts. So our multidimensional array will need to be 10 rows and 4 columns.You should be able to add and remove contacts in the array.

View Replies View Related

Inventory Program - Displaying Information (Input From Array)

Sep 13, 2014

I'm working a an assignment for my IT/215 class and I'm having a little trouble with my arrays. My code compiles just fine but when it comes to displaying the information I've input into my array it doesn't seem to want to and I'm not sure what I'm doing wrong here. On line 136 originally I had [DVDs [count] = count+1]] but it wouldn't compile. I then put line 136 to [ DVDs[count] = new Inventory();] and I think that's were my issue is but I'm not sure....

// Purpose:the purpose of this software is to display inputs as wells as the stocks and price of inputs.

class Inventory
{
private double ItemNumber; //to store Item number
private String ItemName; //to store Item name
private double UnitsInStock; //to store number of units in stock
private double UnitPrice; //to store Unit price
private double InventoryValue; //to store Inventory value
private double TotalInventory; //to store Total Inventory value

[Code] .....

View Replies View Related

Program That Will Allow To Enter Information From Form To Keep Track Of Attorney Who Signed Up

Jan 13, 2015

I work for my local probate court, and one service we offer is email reminders. They fill out a form, it's entered in the system, and they will be notified when something is due. I've been allowed to create a program that will allow me to enter the information from the form to keep track of the attorney's who have signed up.

import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;

public class Attempt1 {
public static void setConnection() throws SQLException {
Connection conn = null;
Statement state = null;

[Code] ....

The issue I have is the method setQuery. It displays a table with the data entered. Where it currently sits at line 21, it does not display the table, nor does it seem to terminate the program. The goal was to update the table with a few entries, and then display the Jtable. When placed above the setInsert method, it displays just fine, and will reflect the new entries added the next time you start it. I'm still learning Java outside of a classroom environment on my own, so I can only imagine that this is riddled with poor coding, but I just can't seem to figure out why it doesn't display the table after the setInsert method is called. In it's current state, this program is just meant to test functions of SQLite with Java. From there it will be created with a GUI.

View Replies View Related

GUI Program Overlay - JButton As Action Item To Display Information To JTextFeilds

Mar 6, 2014

I have some questions about a GUI program overlay. My main method in the "actual code" will display information in a huge batch, which is necessary. My questions relate to this feat. I am curious because I need to look this up but I am unsure of the "name" for what I am trying to accomplish.

Can link a JButton as an action item to display information to the JTextFeilds that houses the information needed to populate the data?

If so, what are the necessary steps to ensure that my JButton class and listener are pulling the correct information upon the Event and populate the data to the JTextFeilds?

Would I need a boolean statement that captures all of the methods of "data procurement" within my JTextFeilds underneath that one button?

View Replies View Related

Program Should Read File Contents And Store Information In Array Of Golfers

Dec 3, 2014

The main method will drive your program by doing the following:

-Create an array to hold all the individual golfers and par scores (type is Golfer[ ]).
-Prompt the user for a data file containing the Par scores and the player names and score. The format of the input file should look like

Par, 3, 4, 4, 3, 4, 3, 5, 3, 4
George, 3, 3, 4, 3, 4, 2, 3, 3, 4
Paul, 4, 5, 4, 3, 6, 3, 4, 3, 5
Ringo, 3, 3, 4, 3, 4, 2, 4, 3, 4
John, 4, 4, 4, 3, 4, 2, 5, 3, 4

Your program should read the file contents and store the information in your array of Golfers.

View Replies View Related

Hurricane Java Project - Read Information From Data File And Run It Through But Program

Dec 2, 2014

I am now stuck. I am writing a program that reads information from a data file and runs it through but program. However, I am almost finished with the program, but cannot figure out the last few parts.

public class Storm {
private final double KnotsToMPH = 1.15;
// global user-defined types:
private int beginDate;
private int duration;
private String name;

[Code] .....

I have not attached the data file because it contains a total of 360 lines of hurricane information.

View Replies View Related

Calculator Program - Print Heart Rate Ranges And User Information

Jan 26, 2014

I am attempting to make a heart rate calculator program. Here is a little overview of what I am trying to do. It must use a constructor and get and set methods. It must print heart rate ranges and the user's information(age).

// Use scanner to get inputs
import java.util.Scanner;
 
// Declare class
public class HeartRates {
private int Age;
private int DayOfBirth;
private int MonthOfBirth;
private int YearOfBirth;
private double MaxHeartRate;
private double MinTargetHeartRate;

[Code] ....

View Replies View Related

How To Remove Objects In Graphics Program

Jul 9, 2014

How to remove multiple objects that are onscreen in a java graphics program(specifically the one from the acm library). The clearAll works fine but I would like to keep the background in my frame. I just want to be able to do something like removing all the trees by typing in a phase into a console program. Here is a small snippet of code with details of what I am trying to achieve.

Java Code:

public void command(){
Dictionary dic=new Dictionary();
//dic list of all phases that will either make animations or remove things in a graphical window
String line = readLine("Type here: ");
if (line.equals(dic.clearActions[i])) {
cleared=true;

[Code] ....

View Replies View Related

Recursive Program - Choose K Objects Out Of N

Apr 20, 2015

I recently wrote a simple recursive program that chooses K objects out of N (I was asked to use the variables N choose the R, however) total objects. Here is the code:

int n = 0;
int r = 0;
//the total number of objects defaults to 0
String nChoice = JOptionPane.showInputDialog(null, "How many objects are there to choose from?");
String rChoice = JOptionPane.showInputDialog(null, "How many object are to be chosen from this group?");
try {
n = Integer.parseInt(nChoice);

[Code] ....

It works fine, however in my class we were given two different formula to implement into our code. I used the one above, obviously. However, the second formula we were given was:

C(n,R) = n!
-------(R!(n-R)!)

I had to get the spacing right.

How do I read this formula? How could it be implemented? What are the benefits (if there are any) from using one method over the other? Which method of calculating N choose K (or, in my case, N choose R) would be more widely accepted?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved