English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Scenario:
Introduction
Your task is to produce a Java simulation of a facility offered by a personal organizer. The personal organizer provides the facility for creating a list of contacts. Entries in this list consist of the name of a person or organization, their telephone number, postal address and e-mail address. The organizer provides the facilities shown below for maintaining and using the list of contacts. Your implementation should provide all the facilities described below. You may use your own creativity in creating the interface of the personal organizer.

Personal Organizer Facilities
Adding new entry
•A new entry may be added to the contacts’ list in the next vacant location.
•A new entry may be added to a specified location in the list where the location is specified by an integer value. How to resolve the problem of the specified location already being occupied is up to you.

Retrieving a contact’s details
•Given an integer value that specifies a location in the list, the details of the entry at that location in the list can be retrieved and displayed.
•Providing a name will retrieve and display the details associated with that name.

Modifying entries
•The phone number or e-mail address number associated with a particular name in the list may be changed.
•A particular entry may be removed from the list.

2006-09-08 03:58:01 · 16 answers · asked by Parves Hossain 1 in Computers & Internet Programming & Design

16 answers

Actually taken at face value it seems pretty simple. Are there any restrictions? For instance are you supposed to provide this functionality using objects or can you do it with arrays? Take a look at this program I did for payroll calculations. A little modifications and it should do the trick.

// File: jpay2.java
// Date: 12/21/04
// Author: Bluescape
// Company: DCDS
// Purpose: Java applet for payroll calculation

// Java packages
import java.awt.Graphics; //class for graphics
import javax.swing.JOptionPane; //class for message box
import javax.swing.JApplet; //class for applets

public class jvpayroll extends JApplet
{
//Declare global variables
int numCtr;
int numCtr2;
int numPrglp;
int numEmp = 5;
int numArryval = numEmp - 1;
double dblFicart = .08;
double dblFedrt = .05;
double dblStatert = .03;
double dblCityrt = .02;
double dblOtpremium = 1.5;
int numPasscode = 1122;
int aryEmpid[] = new int[100];
String aryEmplname[] = new String[100];
String aryEmpfname[] = new String[100];
double aryEmprate[] = new double[100];
double aryEmpwk1hrs[] = new double[100];
double aryEmpwk2hrs[] = new double[100];
double aryEmpothrs[] = new double[100];
double aryEmpreghrs[] = new double[100];
double aryEmpregpay[] = new double[100];
double aryEmpotpay[] = new double[100];
double aryEmpgross[] = new double[100];
double aryEmpficatx[] = new double[100];
double aryEmpfedtx[] = new double[100];
double aryEmpstatetx[] = new double[100];
double aryEmpcitytx[] = new double[100];
double aryEmptotaltx[] = new double[100];
double aryEmpnet[] = new double[100];

public void init()
{
//Call method beginprg to start program
beginprg();

} //End method init

public void paint(Graphics g)
{
//Call superclass version of method paint
super.paint(g);

g.drawRect(10, 10, 325, 50);
g.drawString("Thank you for chosing DCDS as your solution provider", 25, 40);

} //End method paint

public void beginprg()
{
//Declare variables
String stzInpt1;
int numInpt1;

//Input data from user
stzInpt1 = JOptionPane.showInputDialog("Enter 1 to run JVPayroll or 5 to Exit: ");

//Convert string to double
try
{
numPrglp = Integer.parseInt(stzInpt1);
} //end try
catch (NumberFormatException numberFormatException)
{
errormsg("Invaled format.", "Input modicfied to 1.");
numPrglp = 1;
}//End catch

if (numPrglp == 1)
{
for(numCtr=0; numCtr<=99; numCtr++)
{


}//End for loop
mainmenu();
} //End if

} //End method beginprg

public void mainmenu()
{
//Declare variables local to mainmenu
String stzMainMenu;
String stzContinue;
int numMainMenu;
int numContinue;

initarrys();

while (numPrglp == 1)
{
try
{
stzMainMenu = JOptionPane.showInputDialog(
"\n\t\tMain Menu" +
"\n\t\t---------" +
"\n\t 1.) Enter Employee Data" +
"\n\t 2.) Compute Payroll" +
"\n\t 3.) Display Data" +
"\n\t 4.) Change number of Employees" +
"\n\t 5.) Edit Employee Data" +
"\n\t 6.) Change Tax Rate" +
"\n\t 7.) Save Data" +
"\n\t10.) Exit" +
"\nPlease enter selection: ");
numMainMenu = Integer.parseInt(stzMainMenu);

switch(numMainMenu)
{
case 1: //Enter data
stzContinue = JOptionPane.showInputDialog(
"This action will erase all previous employee data." +
"\nTo perform single record update select option 5 from main menu." +
"\nEnter 1 to continue or 5 to return to main menu: ");
numContinue = Integer.parseInt(stzContinue);
if(numContinue == 1)
{
enterdata(0, numArryval);
}//End if
break;
case 2: //Compute
computepay();
break;
case 3: //Display data
displaydata();
break;
case 4: //Change #
initarrys();
break;
case 5: //Edit data
editdata();
break;
case 6: //Change rate
changerate();
break;
case 7: //Save data
savedata();
break;
case 10:
exitprg();
break;
default:
JOptionPane.showMessageDialog(null, "choice entered invalid");
} //End switch for mainmenu
} //End try
catch(NumberFormatException numberFormatException)
{
errormsg("Invalid format.", "Check attempted input and reenter.");
}//End catch
catch(ArithmeticException arithmeticException)
{
errormsg("Invalid Arithmetic Operation.", "Check attempted input and retry.");
}//End catch
} //End while loop for mainmenu
} //End method mainmenu
public void initarrys()
{
//Declare variables local to initarrys
String stzEmp;

stzEmp = JOptionPane.showInputDialog("Please enter number of employees: ");
try
{
numEmp = Integer.parseInt(stzEmp);
}//End try
catch(NumberFormatException numberFormatException)
{
errormsg("Invalid format", "Input modified to 2");
numEmp = 2;
}//End catch
numArryval = numEmp - 1;

} //End method initarrys

public void enterdata(int numLpstart, int numLpend)
{
//Declare variables local to enterdata
String stzEmpid;
String stzEmplname;
String stzEmpfname;
String stzEmprate;
String stzEmpwk1hrs;
String stzEmpwk2hrs;
int numList;

for(numCtr=numLpstart; numCtr<=numLpend; numCtr++)
{
stzEmpid = JOptionPane.showInputDialog(
"Enter ID number for employee # " +
(numCtr+1) + ": ");
stzEmplname = JOptionPane.showInputDialog(
"Enter last name for employee # " +
(numCtr+1) + ": ");
stzEmpfname = JOptionPane.showInputDialog(
"Enter first name for employee # " +
(numCtr+1) + ": ");
stzEmprate = JOptionPane.showInputDialog(
"Enter pay rate for employee # " +
(numCtr+1) + ": ");
stzEmpwk1hrs = JOptionPane.showInputDialog(
"Enter week 1 hours for employee # " +
(numCtr+1) + ": ");
stzEmpwk2hrs = JOptionPane.showInputDialog(
"Enter week 2 hours for employee # " +
(numCtr+1) + ": ");

aryEmpid[numCtr] = Integer.parseInt(stzEmpid);
aryEmplname[numCtr] = stzEmplname;
aryEmpfname[numCtr] = stzEmpfname;
aryEmprate[numCtr] = Double.parseDouble(stzEmprate);
aryEmpwk1hrs[numCtr] = Double.parseDouble(stzEmpwk1hrs);
aryEmpwk2hrs[numCtr] = Double.parseDouble(stzEmpwk2hrs);
}//End for loop
} //End enterdata
public void computepay()
{
//Declare variables local to computepay
double dblWk1othrs;
double dblWk2othrs;
double dblWk1reghrs;
double dblWk2reghrs;

for (numCtr=0; numCtr<=numArryval; numCtr++)
{
if (aryEmpwk1hrs[numCtr] > 40)
{
dblWk1othrs = aryEmpwk1hrs[numCtr] - 40;
}
else
{
dblWk1othrs = 0;
}
if (aryEmpwk2hrs[numCtr] > 40)
{
dblWk2othrs = aryEmpwk2hrs[numCtr] - 40;
}
else
{
dblWk2othrs = 0;
}
dblWk1reghrs = aryEmpwk1hrs[numCtr] - dblWk1othrs;
dblWk2reghrs = aryEmpwk2hrs[numCtr] - dblWk2othrs;
aryEmpothrs[numCtr] = dblWk1othrs + dblWk2othrs;
aryEmpreghrs[numCtr] = dblWk1reghrs + dblWk2reghrs;
aryEmpregpay[numCtr] = aryEmpreghrs[numCtr] * aryEmprate[numCtr];
aryEmpotpay[numCtr] = aryEmpothrs[numCtr] * (aryEmprate[numCtr] * dblOtpremium);
aryEmpgross[numCtr] = aryEmpregpay[numCtr] + aryEmpotpay[numCtr];
aryEmpficatx[numCtr] = aryEmpgross[numCtr] * dblFicart;
aryEmpfedtx[numCtr] = aryEmpgross[numCtr] * dblFedrt;
aryEmpstatetx[numCtr] = aryEmpgross[numCtr] * dblStatert;
aryEmpcitytx[numCtr] = aryEmpgross[numCtr] * dblCityrt;
aryEmptotaltx[numCtr] = aryEmpficatx[numCtr] + aryEmpfedtx[numCtr] + aryEmpstatetx[numCtr] + aryEmpcitytx[numCtr] ;
aryEmpnet[numCtr] = aryEmpgross[numCtr] - aryEmptotaltx[numCtr];
}//End for loop

} //End compute
public void displaydata()
{
for (numCtr=0; numCtr<=numArryval; numCtr++)
{
if (aryEmpid[numCtr] > 0)
{
JOptionPane.showMessageDialog(null,
"Payroll Information for Employee # "+(numCtr+1)+": "+
"\nEmployee ID: \t" + aryEmpid[numCtr] +
"\nLast Name : \t" + aryEmplname[numCtr] +
"\nFirst Name: \t" + aryEmpfname[numCtr] +
"\nPay Rate: \t" + aryEmprate[numCtr] +
"\nWk 1 Hrs: \t" + aryEmpwk1hrs[numCtr] +
"\nWk 2 Hrs: \t" + aryEmpwk2hrs[numCtr] +
"\nReg Pay: \t" + aryEmpregpay[numCtr] +
"\nOT Pay : \t" + aryEmpotpay[numCtr] +
"\nGross : \t" + aryEmpgross[numCtr] +
"\nFICA : \t" + aryEmpficatx[numCtr] +
"\nFed Tax: \t" + aryEmpfedtx[numCtr] +
"\nState Tax: \t" + aryEmpstatetx[numCtr] +
"\nCity Tax : \t" + aryEmpcitytx[numCtr] +
"\nTotal Tax: \t" + aryEmptotaltx[numCtr] +
"\nNet Pay: \t" + aryEmpnet[numCtr] +
"\n");
}//End if
}//End for loop
} //End display
public void editdata()
{
//Declare variables local to editdata
String stzSelection;
int numSelection = -5;
for (numCtr=0; numCtr<=numArryval; numCtr++)
{
stzSelection = JOptionPane.showInputDialog(
"Payroll Information "+
"\nRecord #: " +(numCtr+1)+
"\n Employee ID: \t" + aryEmpid[numCtr] +
"\n Last Name : \t" + aryEmplname[numCtr] +
"\n First Name: \t" + aryEmpfname[numCtr] +
"\n Pay Rate: \t" + aryEmprate[numCtr] +
"\n Wk 1 Hrs: \t" + aryEmpwk1hrs[numCtr] +
"\n Wk 2 Hrs: \t" + aryEmpwk2hrs[numCtr] +
"\nEnter record # to edit or 0 to view next: ");
numSelection = Integer.parseInt(stzSelection);
if ((numSelection - 1) == numCtr)
{
break;
}//end if
}//end for
if (numSelection >= 0)
{
enterdata((numSelection-1), (numSelection-1));
}//End if
} //End method editdata
public void changerate()
{
//Declare variables local to changerate
String stzCodeentered;
String stzFicart;
String stzFedrt;
String stzStatert;
String stzCityrt;
int numCodeentered;

stzCodeentered = JOptionPane.showInputDialog(
"Changing the tax rates requires manager approval." +
"\nPlease enter manager passcode: ");
numCodeentered = Integer.parseInt(stzCodeentered);

if(numCodeentered == numPasscode)
{
stzFicart = JOptionPane.showInputDialog(
"Current FICA rate: "+dblFicart+
"\nPlease enter new FICA rate: ");
dblFicart = Double.parseDouble(stzFicart);
JOptionPane.showMessageDialog(null,
"FICA rate successfully changed." +
"\nNew FICA rate: "+dblFicart);
stzFedrt = JOptionPane.showInputDialog(
"Current Federal tax rate: "+dblFedrt+
"\nPlease enter new Federal tax rate: ");
dblFedrt = Double.parseDouble(stzFedrt);
JOptionPane.showMessageDialog(null,
"Federal tax rate successfully changed." +
"New Federal tax rate: "+dblFedrt);
stzStatert = JOptionPane.showInputDialog(
"Current State tax rate: "+dblStatert+
"\nPlease enter new State tax rate: ");
dblStatert = Double.parseDouble(stzStatert);
JOptionPane.showMessageDialog(null,
"State tax rate successfully changed." +
"New State tax rate: "+dblStatert);
stzCityrt = JOptionPane.showInputDialog(
"Current City tax rate: "+dblCityrt+
"\nPlease enter new City tax rate: ");
dblCityrt = Double.parseDouble(stzCityrt);
JOptionPane.showMessageDialog(null,
"City tax rate successfully changed." +
"New City tax rate: "+dblCityrt);
}//End if

} //End method changerate

public void savedata()
{
JOptionPane.showMessageDialog(null,
"Sorry method currently under construction" +
"\n(savedata)");
} //End method savedata
public void errormsg(String stzType, String stzMsg)
{
JOptionPane.showMessageDialog(null,
"Warning\t: Exception caught" +
"\nType\t: " + stzType +
"\nMessage\t: " + stzMsg);

} //End method erromsg
public void exitprg()
{
//Declare variables local to exitprg
String stzExit;
int numExit;

stzExit = JOptionPane.showInputDialog(
"Warning any unsaved data will be lost" +
"\nEnter 1 to return to main menu or 5 to exit: ");
numExit = Integer.parseInt(stzExit);

if (numExit == 5)
{
numPrglp = numExit;
} //End if
else
{
numPrglp = 1;
} //End else
} //End exitprg
} //End class JVPay2

2006-09-08 04:07:35 · answer #1 · answered by bluescape420 2 · 0 4

Sure, I'll do your assignment for you. And then, when you graduate, I'll take your job, too. Of course, since you won't have learned anything in school, this'll be just as well. I'll be sure to give you a little pat on the back when you're standing in the unemployment line and I'm driving around in a new sportscar.

2006-09-08 04:03:28 · answer #2 · answered by arbeit 4 · 1 0

Oh do the thing yourself.

You are just like my ex-girlfriend who couldn't summarize an assignment specification; it is telling you to write a program similar to Contact in Palm/Pocket PC and other PDAs.

Change major while you are still freshman in college 1st yr.

2006-09-08 04:08:32 · answer #3 · answered by Andy T 7 · 0 0

I would be HAPPY to answer ALL of these questions for you... and any other's you can think of, too. This shouldn't take more than all week-end, but I can have it ready for you to hand in Monday.

I charge the same rates for researching and answering questions that Google Answer's charges, so I should be able to answer all of these questions for a mere $200. Please forward your credit card number... the same one you would use for ordering these answers from Google Answers, and I will get right on it for you.

Thanks for the business.

2006-09-08 04:04:34 · answer #4 · answered by Anonymous · 1 0

I was gonna answer this question in a most negative way but they've all seem to be said so I'll just say, "no you dumbass that's what you're doing homework for...to learn"

2006-09-08 04:07:46 · answer #5 · answered by dslmwgraves 2 · 0 0

Step away from the tv, game boy, xbox, playstation or whatever your lazy butt is doing and do your own homework.

2006-09-08 04:04:28 · answer #6 · answered by keri0426 3 · 0 0

Hey! The answer is 5.

2006-09-08 04:04:16 · answer #7 · answered by Kara 3 · 1 0

You better get busy, I don't think anyone will do your homework assignment for you :)

2006-09-08 04:06:22 · answer #8 · answered by Lisa T 2 · 0 0

try and to it yourself. More self confidence and personal satisfaction in this case.

2006-09-08 04:02:14 · answer #9 · answered by A K 2 · 0 1

Do it yourself. How else can you expect to learn??

2006-09-08 04:03:23 · answer #10 · answered by Demon Doll 6 · 0 0

fedest.com, questions and answers