Java---设计【花店鲜花管理系统】
花店鲜花管理系统
设计要求
王志文演过的电视剧设计花店鲜花管理系统,实现以下功能:
(1)输⼊5种鲜花名称、价格和数量;
(2)统计鲜花的总价格及平均价格、最⾼价和最低价;
(3)按价格降序排序;
(4)统计⾼于平均价格和低于平均价格的鲜花数量;
(5)输⼊鲜花名称查询商品的价格和数量。实现代码package ; import Scanner ;
class Flower { private String name ; private double price ; private int amount ; public Flower () { } public String getName () { return name ; } public void setName (String name ) { this .name = name ; } public double getPrice () { return price ; } public void setPrice (dou
ble price ) { this .price = price ; } public int getAmount () { return amount ; } public void setAmount (int amount ) { this .amount = amount ; }}public class FlowerList { int maxLength = 5; int length = 0; Flower [] data = new Flower [maxLength ];1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
湖北2019高考分数线24玫瑰朵数的含义
25money is not everything
26
27
28
修辞方法有哪些29
30
31
32
33
34
35
36
37
38
39
40
温州旅游41
42
Scanner input = new Scanner (System .in ); public FlowerList () { } //添加记录⽅法 public vo
id add () { if (length < maxLength ) { data [length ] = new Flower (); System .out .print ("请输⼊花名: "); data [length ].setName (input .next ()); System .out .print ("请输⼊花的价格:"); data [length ].setPrice (input .nextDouble ()); System .out .print ("请输⼊花的数量:"); data [length ].setAmount (input .nextInt ()); length ++; System .out .println ("添加成功!"); } else { System .out .println ("添加失败!"); } } //显⽰花名⽅法 public void transcript () { System .out .println ("====================================="); System .out .println (" 花名 价钱 数量 "); for (int i = 0; i < length ; i ++) { System .out .println (data [i ].getName () + "\t" + data [i ].getPrice () + "\t" + data [i ].getAmount ());424344454647484950515253545556575859606162636465666768697071
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论