Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class CompareCharArrays {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String firstArrayString = scanner.nextLine();
- String secondArrayString = scanner.nextLine();
- int firstArraySum = computeUnicodeSum(firstArrayString);
- int secondArraySum = computeUnicodeSum(secondArrayString);
- if (firstArraySum < secondArraySum) {
- System.out.println("first");
- } else if (firstArraySum > secondArraySum) {
- System.out.println("second");
- } else {
- System.out.println("equal");
- }
- }
- private static int computeUnicodeSum(String arrayString) {
- int sum = 0;
- for (char c : arrayString.toCharArray()) {
- sum += c;
- }
- return sum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement