정올 1430 (6일차)
언어/java2020. 4. 30. 23:42
package STU;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
class Num {
public int[] numArry;
public int multiNum;
public String strData;
HashMap<String, Integer> numCnt = new HashMap<String, Integer>();
Num() {
this.numArry = new int[3];
this.multiNum = 1;
}
public void numInit() {
Scanner input = new Scanner(System.in);
for (int i = 0; i < this.numArry.length; i++) {
this.numArry[i] = input.nextInt();
}
} // end of numInit function
public void numMultiple() {
for (int i = 0; i < this.numArry.length; i++) {
this.multiNum *= this.numArry[i];
}
} // end of numMultiple function
public void fromNumToStr() {
this.strData = String.valueOf(this.multiNum);
for (int i = 48; i <= 57; i++) {
char checkVal = (char)i;
int count = 0;
for (int j = 0; j < this.strData.length(); j++) {
if ( checkVal == this.strData.charAt(j) ) {
count += 1;
}
}
numCnt.put(String.valueOf(checkVal), count);
}
} // end of fromNumToStr function
public void resultPrint() {
for (Map.Entry<String, Integer> elem: numCnt.entrySet()) {
System.out.println(String.format("%d", elem.getValue()));
}
} // end of resultPrint function
}
public class Jung1430 extends Num {
public static void main(String[] args) {
Num obj = new Num();
obj.numInit();
obj.numMultiple();
obj.fromNumToStr();
obj.resultPrint();
} // end of main function
}
'언어 > java' 카테고리의 다른 글
1314 정올 (7-2) (0) | 2020.05.02 |
---|---|
1307 정올 7일차 (0) | 2020.05.02 |
정올 2046 (5일차) (0) | 2020.04.30 |
정올 1304 문제 변형 (4일차) (0) | 2020.04.30 |
정올 1856 (d+3) (1) | 2020.04.22 |