我写了一些代码,只是为了好玩,并帮助我熟悉过程。 我对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("");
}
}
任何帮助或指导将不胜感激!
2016-09-19
SykoTron
+0
你可以使用的JOptionPane类https://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane .html例如'JOptionPane.showMessageDialog(null,“Cost to make Shirt:”+“$”+ shirtCost);' –