定义一个Product类,如下:
public class Product {
private String name;//商 品名
private String price;//单价
private String num;//数量
private double total;//商 品总价值
public Product(String name , String price, String num){this . name=name ;
this. price=price;
this . num=num;
public void showTotal(){
//在此完成该商品总价值的计算
System. out . print1n("商品"+name+"的总价值是: "+total)}
在showTotal()方法中补齐代码,利用包装类的方法把String类型转换成数值,计算商品的总价值;
定义一个测试类,在main方法中创建Product对象,并调用它的showTotal()方法。