loops - Printing The Days of The Week In Java -


i'm trying print this:

sun  mon  tue  wed  thur  fri  sat   4    3    8    5     4    4    8 

with user's input of hours worked each day on same line total hours worked can calculated, i'm not sure if that's possible. here's snippet of current code:

system.out.println("\t"+"\t"+"\t"+"\t"+"\t" + "sun" + "\t" + "mon" + "\t" + "tue" + "\t" + "wed" + "\t" + "thur" + "\t" + "fri" + "\t" + "sat");         (int j = 0; j < hoursworkedperday.length; j++) {             system.out.print("enter hours worked employee " + (j+1) + ":"+ "\t" + " " + " ");              (int k = 0; k < hoursworkedperday[0].length; k++) {                 hoursworkedperday[j][k] = scan.nextint();             }         } // end of loop 

and current output:

enter number of employee: 2 enter name of employee 1: jeff enter name of employee 2: lita                                     sun mon tue wed thur fri sat enter hours worked employee 1:    4 6 7 5 8 7 9 enter hours worked employee 2:    3 4 ...... 

my question is, possible or have print each vertically? thanks!

you have print week days before value. this:

//code before string[] weekdays = {"sun","mon","tue", "wed", "thur", "fri", "sat"};     (int k = 0; k < hoursworkedperday[0].length; k++) {         system.out.print(weekdays[k] + ": ");         hoursworkedperday[j][k] = scan.nextint();         system.out.println(); //new line    }  } 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -