View Single Post
  #1 (permalink)  
Old 05-05-2008, 04:47 AM
ubermeister ubermeister is offline
Member
 
Join Date: May 2008
Posts: 12
ubermeister is on a distinguished road
[SOLVED] few steps i need help with
ok this is what my assignment calls for. i need to create a main() function that would implement as having the following steps:

1. creating an object employee1 w/out perameter
2.creating an object employee2 with the following parameters (mary,1111,42000)
3.display employee1 data
4.display employee2 data
5. calling getData function to enter data for employe1
6.redisplaying employee1 data
7. creating an arrary of employee objects with 3 members
8. writing the loop statment to accept data and print data for each of the array member.

this is what i have so far:
Code:
public class TestEmployeeClass { public static void main(String[] args) { EmployeeClass s1= new EmployeeClass(); s1.display(); s1.displayTotal(); EmployeeClass s1= new EmployeeClass(MARY,1111,7500); s1.display(); s1.displayTotal();


THIS code below is the 2nd part to it. (the code below works fine, use as guide for the one above)

Code:
import java.util.Scanner; public class EmployeeClass { static int total=0; //member data String name; int id; double salary; //constructor EmployeeClass() { name=""; id=0; salary=0.0; } EmployeeClass(String n,int i, double s) { name=n; id=i; salary=s; } public void getdata() { Scanner kb= new Scanner(System.in); String s; System.out.print("Enter Name : "); name=kb.nextLine(); System.out.print("Enter ID : "); id=kb.nextInt(); //class buffer s=kb.nextLine(); System.out.print("Enter Salary : "); name=kb.nextLine(); } public void display() { System.out.printf("NAME = %s\n",name); System.out.printf("ID = %s\n",id); System.out.printf("SALARY = %s\n",salary); } }
Reply With Quote
Sponsored Links