MCPcopy Create free account
hub / github.com/Hazrat-Ali9/Computer-Programming / main

Method main

Problem9.java:33–84  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

31 }
32
33 public static void main(String[] args) {
34 // TODO Auto-generated method stub
35 Scanner scan = new Scanner(System.in);
36 int[] primeCount;
37 int N;
38 String line;
39 String[] numbersInALineStr;
40 int[] numbersInALineStrInt;
41
42 N = scan.nextInt();
43 scan.nextLine();
44 primeCount = new int[N];
45
46 for (int i = 0; i < N; i++) {
47 line = scan.nextLine();
48 int individualPrimeCount = 0;
49
50 numbersInALineStr = line.trim().split("\\s+");
51 numbersInALineStrInt = new int[numbersInALineStr.length];
52
53 for (int j = 0; j < numbersInALineStr.length; j++) {
54 numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]);
55 }
56
57 for (int number : numbersInALineStrInt) {
58 while (number < 0 || number > 100) {
59 line = scan.nextLine();
60
61 numbersInALineStr = line.trim().split("\\s+");
62 numbersInALineStrInt = new int[numbersInALineStr.length];
63
64 for (int j = 0; j < numbersInALineStr.length; j++) {
65 numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]);
66 }
67 }
68 }
69
70 for (int j = 0; j < 10; j++) {
71 if (is_prime(numbersInALineStrInt[j]) == 1) {
72 individualPrimeCount++;
73 }
74 }
75
76 primeCount[i] = individualPrimeCount;
77 }
78 scan.close();
79
80 for (int i = 0; i < primeCount.length; i++) {
81 System.out.printf("%d\n", primeCount[i]);
82 }
83
84 }
85
86}

Callers

nothing calls this directly

Calls 1

is_primeMethod · 0.95

Tested by

no test coverage detected