admin管理员组文章数量:1566223
2024年3月31日发(作者:)
public class MainTest {
/**
* 啤酒 3.5元/每罐,方便面 4.5/每包,矿泉水 2.0/每瓶
*小美购买商品:啤酒 3罐,方便面3包,矿泉水2瓶
*小明购买商品:啤酒2罐,方便面5包
*
* @param args
*/
public static void main(String[] args) {
List
//小美购买商品列表
Product beer = new Product("beer", 3.5f, 3);
Product instantNoodle = new Product("instance noodle", 4.5f, ;
Product water = new Product("water", 2.0f, 2);
(beer);
(instantNoodle);
(water);
float totalPrice = 0.0f;
for (Products product : products) {
totalPrice += nt();
}
totalPrice = (float)(totalPrice*100)/100;
n("小美购买商品的总价:" + totalPrice);
//小明购买商品的总价
Product beer2 = new Product("beer", 3.5f, 2);
Product instantNoodle2 = new Product("instance noodle", 4.5f, 5);
();
(beer2);
(instantNoodle2);
float totalPrice2 = 0.0f;
for (Product product : products) {
totalPrice2 += nt();
}
totalPrice2 = (float)(totalPrice2*100)/100;
n("小明购买商品的总价:" + totalPrice2);
}
}
版权声明:本文标题:JAVA语言程序设计形考任务四源代码截图 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1711898829a332915.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论