Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Exercise_07_29.java #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Exercise_07/Exercise_07_29/Exercise_07_29.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public static void pickFourCards(int[] deck) {
public static int sum(int[] deck) {
int sum = 0;
for (int i = 0; i < deck.length; i++) {
sum += ((i + 1) % 13) * deck[i];
if ((i + 1) % 13 == 0)
sum += 13 * deck[i];
else
sum += ((i + 1) % 13) * deck[i];
}
return sum;
}
Expand All @@ -50,4 +53,4 @@ public static void print(int[] deck) {
}
System.out.println();
}
}
}