CSDN成我的问题中心了!这两个代码求编写,大家!!

img

img

package csdn;

import java.util.Scanner;

public class Commun {

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    UnitPrice phone = new phone();
    UnitPrice tv = new phone();
    UnitPrice computre = new phone();
    // 输入空格分隔
    String[] strings = scanner.next().split(" ");
    int[] ints = new int[]{Integer.valueOf(strings[0]),Integer.valueOf(strings[1]),Integer.valueOf(strings[2])};
    System.out.println("总金额为:"+ints[0]*phone.unitprice()+ints[1]*tv.unitprice()+ ints[2]* computre.unitprice());

}

}
class phone implements UnitPrice{

@Override
public double unitprice() {
    return 1.00;
}

}
class tv implements UnitPrice{
@Override
public double unitprice() {
return 2.00;
}
}
class computre implements UnitPrice{
@Override
public double unitprice() {
return 3.00;
}
}