Hello everyone,

I am looking for some assitance with an assignment that requires a user to input tutor time and earnings into a gui and then calculate the totals and averages in a text area. I have succeeded in getting the program to work, however it is totaling the user input after every input, instead of only totalling the entirety after the user has input all the information. I am assuming I have made an error in my nested for loop, however I am not sure what it is, or where to go from here. Does anyone have any ideas? Thank you in advance for any help with this problem.

Here is the code that I have been using to total the time and earnings.

Thank you!

int columns = 2;
int rows = earnings.length;
double totalTime = 0.00; 
double totalPayment = 0.00;
double averageWages =0.00;
double minWage =7.00;

String report="";

for (int j=0;j<columns;j++){
    for(int i=0;i<rows;i++){
        report+= earnings[i][j];

        jTextArea1.append ("Report of your wages to Date\n\n");
        jTextArea1.append ("\n");
        jTextArea1.append("Total Minutes Spent Tutoring = " +totalTime + "\n");        

 if (j==0){
     totalTime+= earnings[i][j];
    }else if(j==1){
        totalPayment+= earnings[i][j];

         jTextArea1.append("Total Earnings = $  " +totalPayment+ "\n");

       if (earnings[0].length>0){
           averageWages = totalPayment/(totalTime/60);

   jTextArea1.append("Average Per Hour Wage  $   " + averageWages + "\n");
   jTextArea1.append("Minimum Wage is currently $6.55");
     jTextArea1.append("Your average wages per hour are below Average");
 }else if(averageWages>=minWage && averageWages<=minWage * 2.00){ 
     jTextArea1.append("Your average wages per hour are average");
 }else if(averageWages > minWage * 2.00){
    jTextArea1.append("Your average wages per hour are above Average"); 




5 Years
Discussion Span
Last Post by NormR1

Can you post the output that shows the problem and add some comments to it that explains what is wrong with it and that shows what the output should be?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.