Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class myPayclass {
- double [] payarray;
- double [] hrsarray;
- double [] totalarray;
- int index;
- public static void main(String[] args){
- /* initialize variables that are available to outside methods */
- int i;
- /*the following method is used to allow for loop to access the array length for count++*/
- myPayclass tm = new myPayclass();
- for (i=0; i< tm.length(); i++)
- {
- /* myarray is not working. It should be diplaying the id of the persons pay rate and hrs */
- String hrs = JOptionPane.showInputDialog( null , i<myarray1.length[3] + "?","Enter the employee's hours");
- String payrate = JOptionPane.showInputDialog("Enter the employee payrate");
- /* must be changed into double from string for math calculations */
- double hrsnum = Double.parseDouble(hrs);
- double paynum = Double.parseDouble(payrate);
- /* we are not sure yet exactly why thi is change or exactly what change()
- * is, or if it is anything else other than a method.*/
- tm.change(hrsnum,paynum);
- /* totalarray shoulf be displaying all the values in the array after 8 entries.*/
- JOptionPane.showMessageDialog(null, tm.totalarray[i], "Printing results",JOptionPane.INFORMATION_MESSAGE);
- }
- }
- /* other half of for loop access to array length */
- public int length(){
- return payarray.length;
- }
- /* this is a debug attempt. myarray1 is still conficting as int */
- public int myarray1(){
- return int myarray1[] = {88761, 89865, 22457, 77541, 7777, 8888, 99999, 7892};
- }
- public int length2(){
- return totalarray.length;
- }
- /* initialize arrays and perform math calc */
- public myPayclass(){
- payarray=new double[8];
- hrsarray=new double[8];
- totalarray=new double[8];
- index = 0;
- }
- /*"My problem is here I am sure. total array should be storing each value but appears to not be*/
- public void change(double paynum,double hrsnum) {
- payarray[index] = paynum;
- hrsarray[index]= hrsnum;
- totalarray[index]=hrsnum * paynum;
- index++;
- /* begin loop to display the inputed values in the array to the screen*/
- if (index == 8) {
- for(int counter=0;counter<totalarray.length;counter++){
- System.out.println(counter + "\t" + totalarray[counter]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement