/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package guessing; import java.util.ArrayList; import java.util.Scanner; /** * * @author HP */ public class Guessing { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner s = new Scanner(System.in); int numberOfCases = s.nextInt(); s.nextLine(); ArrayList<Integer> number = new ArrayList(); for (int i = 0; i < numberOfCases; i++) { int userinput = s.nextInt(); s.nextLine(); if (userinput > 0) { number.add(userinput); } } for (int i = 0; i < number.size(); i++) { int currentnum = number.get(i); int n4 = process(currentnum); currentnum = currentnum * 3; if (currentnum % 2 == 0) { System.out.println("even " + n4); } else if (currentnum % 2 != 0) { System.out.println("odd " + n4); } } } public static int process(int n0) { int n1 = n0 * 3; int n4 = 0; if (n1 % 2 == 0) { n4 = ((n1 / 2) * 3) / 9; } else if (n1 % 2 != 0) { n4 = (((n1 + 1) / 2) * 3) / 9; } return n4; } } /* F:\temp\21711157.138144\Main.java:16: class Guessing is public, should be declared in a file named Guessing.java public class Guessing { ^ Note: F:\temp\21711157.138144\Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error */ |
Double click to view unformatted code.