导入
内置函数和 System.out.println
通过构建你的第一张电子收据,学习 Java 的内置函数以及 System.out.println() 函数。
...
1System.out.println("Hello, World!");
1System.out.println("Hello, World!"); 2System.out.println("Testing, testing.."); 3System.out.println(1); 4System.out.println(2); 5System.out.println(3);
代码示例
1=== MART RECEIPT === 2 3Cashier Name: Alex 4 5Items Purchased: 6Milk (1): 4 7Bread (1): 2 8Eggs (12): 0.5 x 12 = 6 9 10Total bill: 4 + 2 + 6 = 12
1System.out.println("=== MART RECEIPT ==="); 2System.out.println("Cashier Name: Alex");
代码示例
1=== MART RECEIPT === 2Cashier Name: Alex
代码示例
1编写一个 Java 程序,仅使用 System.out.println() 语句打印出以下收据: 2 3=== MART RECEIPT === 4 5Cashier Name: Alex 6 7Items Purchased: 8Milk (1): 4 9Bread (1): 2 10Eggs (12): 0.5 x 12 = 6 11 12Total bill: 4 + 2 + 6 = 12
PageFlux AI 助手
💡 选中文本后点击"AI 询问",或 Ctrl+Enter 发送消息
1class Receipt { 2 public static void main( String args[] ) { 3 // 编写生成收据的代码 4 } 5}
代码示例
1=== MART RECEIPT === 2Cashier Name: Sam 3 4Items Purchased: 5Pen (1): 20 6Notebook (1): 45 7Bag (1): 120 8 9Total bill: 20 + 45 + 120 = 185
1class Receipt { 2 public static void main( String args[] ) { 3 // 在此处编写你的代码 4 } 5}