Java 为什么我的输出不';不显示我的输入?

Java 为什么我的输出不';不显示我的输入?,java,Java,我不确定需要做什么才能使“采购摘要”的输出显示“汽油类型”。感谢您的帮助 更新:完整代码。汽油类型的“String type=input.nextLine();”在运行时似乎未在采购摘要中注册。我不确定这里面有什么问题 class PetrolPurchase { private String station; private double quant; private String type; private double price; priva

我不确定需要做什么才能使“采购摘要”的输出显示“汽油类型”。感谢您的帮助

更新:完整代码。汽油类型的“String type=input.nextLine();”在运行时似乎未在采购摘要中注册。我不确定这里面有什么问题


class PetrolPurchase  
{
    private String station;
    private double quant;
    private String type;
    private double price;
    private int discount;
    
    public String getstation () {return station;}
    public double getquant () {return quant;}
    public String gettype () {return type;}
    public double getprice () {return price;}
    public int getdiscount () {return discount;}
    
    public void setstation (String otherstation) {station = otherstation;}
    public void setquant (double otherquant) {quant = otherquant;}
    public void settype (String othertype) {type = othertype;}
    public void setprice (double otherprice) {price = otherprice;}
    public void setdiscount (int otherdiscount) {discount = otherdiscount;}
    
        
}

class PurchaseSummary 
{ public static void main (String [ ] args)
    {       
Scanner input = new Scanner (System.in); 

        PetrolPurchase pp = new PetrolPurchase  ();
        
        System.out.printf ("Enter Station:");
        String station = input.nextLine();
        pp.setstation (station);
        
        System.out.printf("Enter Quantity (Liter):");
        double quant = input.nextDouble();
        pp.setquant (quant);
        
        System.out.printf ("Enter Petrol Type:");
        String type = input.nextLine();
        pp.settype (type);
        input.nextLine();
        
        System.out.printf ("Enter the Petrol Price:");
        double price = input.nextDouble();
        pp.setprice (price);
        
        System.out.printf("Enter the discount (no decimal):");
        int discount = input.nextInt();
        pp.setdiscount (discount); 
        
        double truecost = quant * price;
        double dcost = discount*0.01*truecost;
        double pay = truecost - dcost;
        
        
        System.out.printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%n");
        System.out.printf("Purchase Summary:%n");
        System.out.printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%n");
        System.out.printf ("Station: %s%n", station);
        System.out.printf ("Total Petrol Liter: %s%n", pp.getquant ());
        System.out.printf ("Petrol Type: %s%n", pp.gettype());
        System.out.printf ("Price Per Liter: = %.2f%n", pp.getprice ());
        System.out.printf ("Actual Cost = %.2f%n", truecost);
        System.out.printf ("Discounted Amount %s", discount);
        System.out.printf ("%% is: %-8.5s", dcost);
        System.out.printf ("%nAmount for Payment = %.2f%n", pay);


尝试输入
input.nextLine()
before
type=input.nextLine()

这个问题看起来不完整。您可以添加打印整个摘要的代码吗?也可以使用
camelCase
作为您的getter和setter。谢谢@Frakcool。成功了。