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

Method main

Problem17.java:7–41  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

5public class Problem17 {
6
7 public static void main(String[] args) {
8 // TODO Auto-generated method stub
9 Scanner scan = new Scanner(System.in);
10 int[] amounts;
11 int N, wordCount;
12 String advert;
13
14 N = scan.nextInt();
15 while (N < 1) {
16 N = scan.nextInt();
17 }
18 scan.nextLine();
19
20 amounts = new int[N];
21
22 for (int i = 0; i < amounts.length; i++) {
23 advert = scan.nextLine();
24
25 wordCount = advert.trim().split("\\s+").length;
26
27 while (wordCount < 1 || wordCount > 1000) {
28 advert = scan.nextLine();
29
30 wordCount = advert.trim().split("\\s+").length;
31 }
32
33 amounts[i] = wordCount * 420;
34 }
35 scan.close();
36
37 for (int amount : amounts) {
38 System.out.printf("%d\n", amount);
39 }
40
41 }
42
43}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected