top of page

Forum Comments

LOL Contest Results! [Updated Weekly]
In LOL News
hastin.chen
Jul 09, 2023
done! this will be seen next week
Run for 2023-2024 LoL VP Curricula - Post and Vote Here!
In LOL News
6/26 Postfix, Prefix, and Infix notation
In Java for ACSL
hastin.chen
Jun 26, 2022
hi guys
0
0
10/19 Homework: Recursion
In CS Fundamentals for ACSL
hastin.chen
Oct 25, 2020
import java.util.Scanner; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner in = new Scanner(new FileReader("input.txt")); in.useDelimiter(", |\\s|,"); int cards, reference, best_value; String suits, best_suit; int[] card_numbers = new int[6]; String[] card_suits = new String[6]; for (int repeating_times = 0; repeating_times < 5; repeating_times++){ reference = 0; best_suit = "NONE"; best_value = 10; cards = in.nextInt(); suits = in.next(); card_numbers[reference] = cards; card_suits[reference] = suits; reference++; cards = in.nextInt(); suits = in.next(); card_numbers[reference] = cards; card_suits[reference] = suits; reference++; cards = in.nextInt(); suits = in.next(); card_numbers[reference] = cards; card_suits[reference] = suits; reference++; cards = in.nextInt(); suits = in.next(); card_numbers[reference] = cards; card_suits[reference] = suits; reference++; cards = in.nextInt(); suits = in.next(); card_numbers[reference] = cards; card_suits[reference] = suits; reference++; cards = in.nextInt(); suits = in.next(); card_numbers[reference] = cards; card_suits[reference] = suits; // This is the first case, does nothing to best_value if it does not exist. for (int i = 1; i < 6; i++){ if (card_suits[0].equals(card_suits[i])){ best_suit = card_suits[0]; if (card_numbers[i] > card_numbers[0] && best_value > card_numbers[i]){ best_value = card_numbers[i]; } } } //If the first case is not satisfied, then this calculates the smallest of the same suit. if (best_value == 10) { for (int i = 1; i < 6; i++){ if (card_suits[0].equals(card_suits[i])){ if (card_numbers[i] < card_numbers[0] && card_numbers[i] < best_value){ best_value = card_numbers[i]; } } } } //If no cases are satisfied, then this does either NONE or the best choice of card. if (best_suit.equals("NONE")){ System.out.println("NONE"); } else { System.out.println(best_value + ", " + best_suit); } } } } 2. 22
0
0
9/21 Homework: Computer Number Systems 2
In CS Fundamentals for ACSL
9/13 Homework: Computer Number Systems 1
In CS Fundamentals for ACSL
6/24 Homework: Prefix/Postfix notation
In CS Fundamentals for ACSL

hastin.chen

Forum Moderator
More actions
bottom of page