Hey guys,
I have this HW for school for Java but I just can't seem to figure it out. I know I have to use a for loop for it but I just can't seem to figure out everything else. Thanks :D

use a for loop, and have an answer variable that is set to 1. then decrement the for loop, and then multiply the number in the for loop to the number in the answer, and once you are done return the answer.

I just did this but can you guys please explain why its this?

public class bob
{
public static void main(String args[]) {
int n=7;
int fact=1;
for(int i=1; i<=n; i++)
{
fact=fact*i;
}
System.out.println (fact);
}
}

no. instead of adding you want to subtract. and the n is the factorial (in your case 7, so 7 x 6 x 5 x 4 x 3 x 2 x 1). so you want to use n in your for loop. and you want to decrement to follow the pattern. then your fact value if your answer, so the operation would look like this

no. instead of adding you want to subtract. and the n is the factorial (in your case 7, so 7 x 6 x 5 x 4 x 3 x 2 x 1).

I don't understand why you have rejected the OP's solution just because it computes the answer in the order 1 x 2 x 3 x 4 x 5 x 6 x 7. The end result is that same.

@xiangzhuang: "I just did this but can you guys please explain why its this?"
That's a very strange question. If you just did that you must know why you did it that way. Is it possible that you copied that code form someone/somewhere else?

I thing the OP was asking why this (solution) works.
Whether you are looping from 1 to 7, or 7 down to 1, makes no difference.
You're just multiplying everything together.

I'm sorry I didn't notice that.. It doesn't make a difference because when you multiply the order doesn't matter. it is only when you are adding and multiplying in the same command. for example if you multiply 5 x 4 x 3 you get 60, and if you do (5 x 5) + 5 which gives an answer of 30, or if you do 5 * (5 + 5) which gives you an answer of 50. This is the reason BEDMAS was created.

Also the reason I rejected it was because factorials go from the highest number down. So I wanted to keep the factorial method the same as what a factorial is, but it doesn't actually matter.

@carlosreg: That's just a scruffy version of the code that xiangzhuang posted earlier in this thread, except that his version works and yours does not.
You can avoid much embarrassment by (a) reading the whole thread and (b) testing your code for elementary errors before posting.

Hi,
I have a DGV (dgvListOfJobs), populated from an SQL database to show the user a list of 'jobs' (i.e. rows). I also show 7 other DGV's (dgvMonday, dgvTuesday, etc) ...

Write a looping program for Theater Seating selection
The program will display the theater seating (shown later) and prompt the user to select a seat to purchase using the row ...