如何用Java制作销货单?

问题遇到的现象和发生背景

练习不用表格搭建一个销货单

问题相关代码,请勿粘贴截图

第一个:
import java.util.Scanner;
public class Assignment23 {
public static void main(String[] args) {//无法打出用“代替”
String d1
4;
short h4, q4;
double aa4,r4, total, discount, tax, sgst, cgst, pay;
Scanner input=new Scanner(System.in);
System.out.print("Enter the Item Name:");
d1 = input.next();
System.out.print("Enter the Item's HSN:");
h1 = input.nextShort();
System.out.print("Enter the Item's QTY:");
q1 = input.nextShort();
System.out.print("Enter the Item's RATE:");
r1 = input.nextDouble();

    System.out.print("Enter the Item Name:"); 
    d2 = input.nextLine();
    System.out.print("Enter the Item's HSN:");
    h2 = input.nextShort();
    System.out.print("Enter the Item's QTY:");
    q2 = input.nextShort();
    System.out.print("Enter the Item's RATE:");
    r2 = input.nextDouble();
    
    System.out.print("Enter the Item Name:"); 
    d3 = input.nextLine();
    System.out.print("Enter the Item's HSN:");
    h3 = input.nextShort();
    System.out.print("Enter the Item's QTY:");
    q3 = input.nextShort();
    System.out.print("Enter the Item's RATE:");
    r3 = input.nextDouble();
    
    System.out.print("Enter the Item Name:"); 
    d4 = input.nextLine();
    System.out.print("Enter the Item's HSN:");
    h4 = input.nextShort();
    System.out.print("Enter the Item's QTY:");
    q4 = input.nextShort();
    System.out.print("Enter the Item's RATE:");
    r4 = input.nextDouble();
    
    a1 = q1 * r1;
    a2 = q2 * r2;
    a3 = q3 * r3;
    a4 = q4 * r4;
    
    total = a1+a2+a3+a4;
    discount = total * 0.01;
    tax= total + discount;
    sgst= tax * 0.06;
    cgst= tax * 0.09;
    pay= tax +sgst +cgst;
    System.out.println(total);

第二个:
import java.util.Scanner;
public class Assignment23 {
public static void main(String[] args) {
String d;
short h, q;
double r,a,discount, tax, sgst, cgst, pay, total=0;
Scanner input=new Scanner(System.in);
for (int i=1; i<=4; i++)
{
System.out.print("Enter the Item Name:");
d = input.nextLine();
System.out.print("Enter the HSN:");
h = input.nextShort();
System.out.print("Enter the QTY:");
q = input.nextShort();
System.out.print("Enter the RATE:");
r = input.nextDouble();
a = q * r;
System.out.println(i + "\t" + d +"\t" + h + "\t" + q +"\t" +"Rs. " + r + "\t" + "Rs. " +a);
total = total +a;
i = i++;
}
System.out.println(total);
}}

运行结果及报错内容

Enter the Item Name:heheh43
Enter the Item's HSN:35
Enter the Item's QTY:4553
Enter the Item's RATE:24
Enter the Item Name:Enter the Item's HSN:
变量d系列和h系列显示未读取过

我的解答思路和尝试过的方法

两种方式最后框架未搭建。
第一种尝试死脑筋要求写四个项目,就一一输入,但还是遇到跳过输入的item name的问题
第二种出了遇到跳过输入的item name的问题外,不知道该如何让最后统一输出,而不是一行一行输出

我想要达到的结果

img


红色为输入,蓝色为输出。
感觉用循环做才是正道,但因为初学,无从下手