java设置发票打印格式

2025-10-07 21:55:32

1、在一个文件中创建一个商品类:

package carlos.way;

/**

 * 商品

 * @author Mr.zhang

 *

 */

public class Shipping {

    String no;

    String name;

    int count;

    double price;

    double sum;

}

java设置发票打印格式

2、在另一个文件中实现发票打印:

package carlos.way;

import java.math.RoundingMode;

import java.util.Scanner;

public class TrueList {

    public static void main(String[] args) {

        int i = 1;

        while (i != -1) {

java设置发票打印格式

3、            // 商品报价单

            System.out.println("商品信息:");

            System.out.println("文明之光:¥59.00");

            System.out.println("大学之路:¥72.00");

            System.out.println("硅谷之谜:¥59.00");

            System.out.println("输入1:开始购物");

            Scanner sc1 = new Scanner(System.in);

            int no1 = sc1.nextInt();

            if (no1 == 1) {

    

java设置发票打印格式

4、            // 订单信息

                String[] up = new String[6];

                up[0] = "35201747366";

                up[1] = "×××";

                up[2] = "¥0.00";

                up[3] = "¥0.00";

                up[4] = "¥0.00";

                up[5] = "2020-01-01";

                // 文明之光

                Shipping first = new Shipping();

                first.no = "23494125";

                first.name = "文明之光";

                System.out.println("请输入第一件物品的购买的数量");

                Scanner sc2 = new Scanner(System.in);

                first.count = sc2.nextInt();

                first.price = 59.00;

                first.sum = first.count * first.price;

   

java设置发票打印格式

5、             // 大学之路

                Shipping second = new Shipping();

                second.no = "23750508";

                second.name = "大学之路";

                System.out.println("请输入第二件物品的购买的数量");

                Scanner sc3 = new Scanner(System.in);

                second.count = sc3.nextInt();

                second.price = 72.00;

                second.sum = second.count * second.price;

java设置发票打印格式

6、                // 硅谷之谜

                Shipping third = new Shipping();

                third.no = "23813967";

                third.name = "硅谷之谜";

                System.out.println("请输入第三件物品的购买的数量");

                Scanner sc4 = new Scanner(System.in);

                third.count = sc4.nextInt();

                third.price = 72.00;

                third.sum = third.count * third.price;

java设置发票打印格式

7、                // 结账or退出

                System.out.println("输入2:结账,并打印小票");

                System.out.println("输入3:不想买了,直接退出");

                Scanner sc5 = new Scanner(System.in);

                int no2 = sc5.nextInt();

                if (no2 == 2) {

java设置发票打印格式

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢