java设置发票打印格式

 时间:2026-02-14 12:17:55

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设置发票打印格式

  • Qt怎样实现换肤
  • vivos10pro怎样开启画o唤醒qq功能
  • mysql的服务器无法启动,如何设置?
  • 在线报表FineReport中如何进行日志查看
  • 计算机选项卡浏览怎么设置
  • 热门搜索
    生活常识趣味问答题 抱歉近义词 好听的近义词 齐肩短发发型 韩式发型男 膏药过敏怎么办 金伯利钻石怎么样 凝望的近义词是什么 四季豆怎么做好吃 严肃的近义词