導入包:Import java .util.Scanner; Scanner input=new Scanner(System.in); double num=new input.nextDouble();//從鍵盤讀入一個數值,并且將數值付給雙精度num; byte byteValue=input.nextByte();//從鍵盤讀入一個數值,并且將數值付給byte 類型byteValue; short shortValue =input.nextShort();//從鍵盤讀入一個數值,并且將數值付給short型 shortValue; int intValue=input.nextInt();//從鍵盤讀入一個數值,并且將數值付給整型intValue; long longValue=input.nextLong();//從鍵盤讀入一個數值,并且將數值付給longValue; float floatValue=input.nextFloat();從鍵盤讀入一個數值,并且將數值付給floatValue;
導入包:import javax.swing.JOptionPane; String num=JOptionPane.showInputDialog(“Enter yearly interest rate,for example:8.25”);//在對話框出現的提示語: double num1=Double.parseDouble(num);//將從對話框輸入的數附給num1
String output =”The monthly payment is”+num1; //對話框輸出的內容 JOptionPane.showMessageDialog(null,output) ***JOptionPane.showMessageDialog(null,“/u6B22/u8FCE/U03b1/u03B3”, “/u6B22/u8FCE Welcome“JOptionPane.INFORMATTON_MESSAGE); //u6B22/u8FCE/U03b1/u03B3!對應對話框中的 //u6B22/u8FCE Welcome對應對話框中的
//JOptionPane.INFORMATTON_MESSAGE!對應對話框中的

新聞熱點
疑難解答