首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

税收征缴系统

2012-11-01 
税收征收系统????+ de.format(getPrice()) + \t + de.format(getTax() * getNum())????+ \t + de.form

税收征收系统

????+ de.format(getPrice()) + "\t" + de.format(getTax() * getNum())
????+ "\t" + de.format(sumPrice());
?}

?// 录入数据
?public static Vector<Product> add() {

??Vector<Product> products = new Vector<Product>();

??while (true) {
???System.out.println("请输入产品名称");
???String name = in.next();
???System.out.println("请输入产品类型");
???String type = in.next();
???System.out.println("请输入产品数量");
???int num = in.nextInt();
???System.out.println("请输入产品价格");
???double price = in.nextDouble();

???Product product = new Product(name, type, num, price);
???products.add(product);

???//询问是否继续录入数据
???System.out.println("是否继续输入?Y/N");
???String select = in.next();
???if (select.equals("N")) {
????break;
???}
??}
??return products;
?}

?// 打印数据
?public static void prtn(Vector<Product> products) {
??System.out.println("产品名称" + "\t" + "产品类型" + "\t" + "产品数量" + "\t"
????+ "产品价格" + "\t" + "税收" + "\t" + "合计");

??int count = products.size(); // 总的记录个数
??int sumNum = 0; // 计算产品总的数量
??double sumPrice1 = 0; // 计算每个产品的总价钱
??double sumPrice2 = 0;// 计算所有产品的价格
??double tax = 0;// 每个产品应交的税
??double sumTax = 0; // 总税收

??for (Product product : products) {
???System.out.println(product);
???sumNum += product.getNum();
???sumPrice1 += product.getPrice();
???sumPrice2 += product.sumPrice();
???tax = product.getTax() * product.getNum();
???sumTax += tax;
??}
??System.out.println("总计" + "\t" + count + "\t" + sumNum + "\t"
????+ de2.format(sumPrice1) + "\t" + de2.format(sumTax) + "\t"
????+ de2.format(sumPrice2));
?}

?public static void operation() {
??System.out
????.println("------------------------欢迎使用本系统-------------------------------");
??System.out.println("1:数据录入" + "\t" + "\t" + "2:退出");
??while (true) {
???System.out.println("请选择操作...");
???String str = in.next();
???if (str.equals("1")) {
????prtn(add()); //进行数据录入工作
???} else if (str.equals("2")) {
????System.exit(0); // 退出程序
???}
???//询问是否继续操作
???System.out.println("是否继续操作?Y/N");
???String select = in.next();
???if (select.equals("N")) {
????break;
???}
??}
?}

?public static void main(String[] args) {
??operation();
?}

}

运行过程:

------------------------欢迎使用本系统-------------------------------
1:数据录入??2:退出
请选择操作...
1
请输入产品名称
1
请输入产品类型
食品
请输入产品数量
78
请输入产品价格
1
是否继续输入?Y/N
N
产品名称?产品类型?产品数量?产品价格?税收?合计
1?食品?78?1.00?3.90?78.00
总计?1?78?1.00?3.90?78.00
是否继续操作?Y/N
Y
请选择操作...
1
请输入产品名称
2
请输入产品类型
药品
请输入产品数量
23
请输入产品价格
4
是否继续输入?Y/N
Y
请输入产品名称
3
请输入产品类型
食品
请输入产品数量
23
请输入产品价格
5
是否继续输入?Y/N
N
产品名称?产品类型?产品数量?产品价格?税收?合计
2?药品?23?4.00?0.00?92.00
3?食品?23?5.00?5.75?115.00
总计?2?46?9.00?5.75?207.00
是否继续操作?Y/N

热点排行