我寫了一些代碼,只是爲了好玩,並幫助我熟悉過程。 我對Java編程非常陌生,所以請耐心等待。如何將Java打印到窗口
目前,我只是在Notepad ++中撰寫並在命令提示符下編譯,但我想了解如何編譯並將輸出結果打印到窗口,而不是打印到命令提示符中。
public class SalesCalculations {
public static void main (String args[]){
//This section is shirt sales calculations
int shirtCost;
shirtCost = 12;
int shirtSales;
shirtSales = 200;
int shirtSalePrice;
shirtSalePrice = 25;
int shirtMakeCost;
shirtMakeCost = shirtCost * shirtSales;
int shirtSaleTotal;
shirtSaleTotal = shirtSalePrice * shirtSales;
int shirtProfit;
shirtProfit = shirtSaleTotal - shirtMakeCost;
System.out.println("");
System.out.println("Cost to make Shirt: " + "$" + shirtCost);
System.out.println("Sales Price of Shirt: " + "$" + shirtSalePrice);
System.out.println("Number of Shirt sales: " + shirtSales);
System.out.println("This months Shirt making price: " + "$" + shirtMakeCost);
System.out.println("Shirt sales money this month: " + "$" + shirtSaleTotal);
System.out.println("Profit of Shirts: " + "$" + shirtProfit);
System.out.println("");
}
}
任何幫助或指導將不勝感激!
你可以使用的JOptionPane類https://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane .html例如'JOptionPane.showMessageDialog(null,「Cost to make Shirt:」+「$」+ shirtCost);' –