20220208 º¹½À
Ƽ¼ÅÃ÷ÀÇ »çÀÌÁ °³¼ö¸¦ Ä«¿îÆ®Çϱâ
class T0207_28//CosPro 1¹ø ¹®Á¦(»çÀÌÁ °³¼ö¸¦ ´ãÀº ¹è¿ ¸¸µé±â)
{
static int[] solution(String[] shirtSize) {
int[] shirt_cnt = new int[6];
for (int i=0;i<shirtSize.length;i++) {
switch (shirtSize[i]) {
case "XS":
shirt_cnt[0]++;
break;
case "S":
shirt_cnt[1]++;
break;
case "M":
shirt_cnt[2]++;
break;
case "L":
shirt_cnt[3]++;
break;
case "XL":
shirt_cnt[4]++;
break;
case "XXL":
shirt_cnt[5]++;
break;
}
}
return shirt_cnt;
}
static void print(int[] a){
for(int i=0;i<a.length;i++){
System.out.printf("[%2d]",a[i]);
}
}
public static void main(String[] args) {
String[] shirtSize = new String[]{"XS", "S", "L", "L", "XL", "S"};
int[] result=solution(shirtSize);
System.out.println(solution(shirtSize));
print(solution(shirtSize));
}
}
µî±Þº° ÇÒÀÎÀ²À» Àû¿ëÇÑ °¡°Ý ±¸Çϱâ
class T0208_29//CosPro 2¹ø ¹®Á¦(µî±Þº° ÇÒÀÎÀ°À» Àû¿ëÇÑ °¡°Ý)
{
static int solution(int a, String b){
if(b.equals("S")){
a=(int)(a*0.95);
}else if(b.equals("G")){
a=(int)(a*0.9);
}else if(b.equals("V")){
a=(int)(a*0.85);
}
return a;
}
public static void main(String[] args)
{
int price=2500;
String grade="V";
int price2=96900;
String grade2="S";
solution(price, grade);
solution(price2, grade2);
System.out.println("°¡°Ý: "+price+" µî±Þ: "+grade);
System.out.println(" ÇÒÀÎ ÈÄ °¡°Ý: "+solution(price, grade));
System.out.println("°¡°Ý: "+price2+" µî±Þ: "+grade2);
System.out.println(" ÇÒÀÎ ÈÄ °¡°Ý: "+solution(price2, grade2));
}
}
µî±ÞÇ¥ À¥À¸·Î ¿Å°Üº¸±â
/study/shop.html