標題:
資料輸入 (二)
[打印本頁]
作者:
tonyh
時間:
2019-7-1 15:18
標題:
資料輸入 (二)
運用套件 java.io 下的 Console 類別, 作整數與浮點數的輸入練習.
提示: 需搭配 parseInt() 或 parseFloat() 方法, 進行資料型態的轉換
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數: ");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入: "+x);
System.out.print("輸入一浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入: "+y);
}
}
複製代碼
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
x=Integer.parseInt(c.readLine("輸入一整數: "));
System.out.println("剛輸入: "+x);
y=Float.parseFloat(c.readLine("輸入一浮點數: "));
System.out.println("剛輸入: "+y);
}
}
複製代碼
作者:
古蕾娜
時間:
2019-7-1 15:48
本帖最後由 古蕾娜 於 2019-7-1 15:50 編輯
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("Enter a whole number: ");
x=Integer,parseInt(c.readLine());
System.out.printlm("The whole number you just entered: "+x);
System.out.print("Enter a decimal number: ");
y=Float.parseFloat(c.readLine());
System.out.print("The decimal number you just entered: "+y);
}
}
複製代碼
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
x=Integer,parseInt(c.readLine("Enter a whole number: "));
System.out.printlm("The whole number you just entered: "+x);
y=Float.parseFloat(c.readLine("Enter a decimal number: "));
System.out.print("The decimal number you just entered: "+y);
}
}
複製代碼
作者:
劉欽文
時間:
2019-7-1 15:49
本帖最後由 劉欽文 於 2019-7-1 15:54 編輯
import java.io.Console;
public class Ch04
{
public static void main(String args[])
{
int x;
float y;
Console c=System.Console();
x=Integer.parseInt(c.readLine("輸入一整數: "));
System.out.println("剛輸入: "));
y=Float.parseFloat(c.readLine:("輸入一浮點數: "));
System.out.println("剛輸入: "+y);
}
}
}
複製代碼
import java.io.Console;
public class Ch05
{
public static void main(String args[])
{
int x;
float y;
Console c=System.Console();
System.out.println ("輸入一整數: "));
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入: "+x));
System.out.println ("輸入一浮點數: "))
y=Float.parseFloat(c.readLine:());
System.out.println("剛輸入: "+y);
}
}
}
複製代碼
作者:
李承洋
時間:
2019-7-1 15:50
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("請輸入一個整數: ");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入的數是: "+x);
System.out.print("請輸入一個浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入的數是: "+y);
}
}
複製代碼
作者:
宋威廷
時間:
2019-7-1 15:52
import java.io.Console;
public class CH06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
x=Integer.parseInt(c.readLine("輸入一整數:"));
System.out.println("剛輸入:"+x);
y=Float.parseFloat(c.readLine("輸入一浮點數:"));
System.out.println("剛輸入:"+y);
}
}
複製代碼
作者:
李佳諭
時間:
2019-7-1 15:53
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數:");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入:"+x);
System.out.print("輸入一浮點數:");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入:"+y);
}
}
複製代碼
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
x=Integer.parseInt(c.readLine("輸入一整數:"));
System.out.println("剛輸入:"+x);
y=Float.parseFloat(c.readLine("輸入一浮點數:"));
System.out.println("剛輸入:"+y);
}
}
複製代碼
作者:
陳璽安
時間:
2019-7-1 15:53
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數: ");
x=Lnteger.parselnt(c.readLine());
System.out.println("剛輸入: "+x)");
System.out.print("輸入一浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入: "+y)");
}
}
複製代碼
作者:
李沛儒
時間:
2019-7-1 15:54
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x ;
float y ;
Console c=System.console();
x=Integer.parseInt(c.readLine("輸入一整數: "));
System.out.println("剛輸入: "+x);
y=Float.parseFloat(c.readLine("輸入一浮點數: "));
System.out.println("剛輸入: "+y);
}
}
複製代碼
作者:
蔡杰恩
時間:
2019-7-1 15:55
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數:");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入:"+x);
System.out.print("輸入一浮點數:");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入:"+y);
}
}
複製代碼
import java.io.Console;
public class Ch07
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
x=Integer.parseInt(c.readLine("輸入一整數:"));
System.out.println("剛輸入:"+x);
y=Float.parseFloat(c.readLine("輸入一浮點數:"));
System.out.println("剛輸入:"+y);
}
}
複製代碼
作者:
吳庭慈
時間:
2019-7-1 15:56
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數: ");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入: "+x);
System.out.print("輸入一浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入: "+y);
}
}
複製代碼
作者:
陳智鈞
時間:
2019-7-1 15:56
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數: ");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入: "+x);
System.out.print("輸入一浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入: "+y);
}
}
複製代碼
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
x=Integer.parseInt(c.readLine("輸入一整數: "));
System.out.println("剛輸入: "+x);
y=Float.parseFloat(c.readLine("輸入一浮點數: "));
System.out.println("剛輸入: "+y);
}
}
複製代碼
作者:
王煦
時間:
2019-7-1 15:56
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
x=Integer.parseInt(c.readLine("輸入一整數:"));
System.out.println("剛輸入:"+x);
y=Float.parseFloat(c.readLine("輸入一浮點數:"));
System.out.println("剛輸入:"+y);
}
}
複製代碼
作者:
蔡杰希
時間:
2019-7-1 15:56
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入: "+x);
System.out.print("輸入一浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入: "+y);
}
}
複製代碼
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
x=Integer.parseInt(c.readLine("輸入一整數: "));
System.out.println("剛輸入: "+x);
y=Float.parseFloat(c.readLine("輸入一浮點數: "));
System.out.println("剛輸入: "+y);
}
複製代碼
作者:
林宥杰
時間:
2019-7-1 15:57
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數: ");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入:" +x);
System.out.print("輸入一浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入: "+y);
}
}
複製代碼
作者:
張啟廣
時間:
2019-7-1 15:57
import java.io.Console;
public class Ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數: ");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入: "+x);
System.out.print("輸入一浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入: "+y);
}
}
複製代碼
作者:
古昇暘
時間:
2019-7-1 15:58
import java.io.Console;
public class Cl06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out .print("Please enter a whole number: ");
x=Integer.parseInt(c.readLine());
System.out.println("Your entered: "+x);
System.out .print("Please enter a decimal number: ");
y=Float.parseFloat(c.readLine());
System.out.println("Your entered: "+y);
}
}
複製代碼
import java.io.Console;
public class Cl07
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
//System.out .print("Please enter a whole number: ");
x=Integer.parseInt(c.readLine("Please enter a whole number: "));
System.out.println("Your entered: "+x);
// System.out .print("Please enter a decimal number: ");
y=Float.parseFloat(c.readLine("Please enter a decimal number: "));
System.out.println("Your entered: "+y);
}
}
複製代碼
作者:
李從赫
時間:
2019-7-1 15:58
[code][code]import java.io.Console;
public class Ch06
{
public static void main (String args[])
{
int x;
float y;
Console c=System.console();[code]import java.io.Console;
public class Ch06
{
public static void main (String args[])
{
int x;
float y;
Console c=System.console();
x=Integer.parseInt(c.readLine("輸入一整數: "));
System.out.println("剛輸入: "+x);
y=Float.parseFloat(c.readLine("輸入一浮點數: "));
System.out.println("剛輸入: "+y);
}
}
複製代碼
System.out.print("輸入一整數: ");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入: "+x);
System.out.print("輸入一浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入: "+y);
}
}[/code][/code][/code]
作者:
葉子于
時間:
2019-7-1 16:00
import java.io.Console;
public class ch05
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("請輸入一整數: ");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入:"+x);
System.out.print("請輸入一浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入:"+y);
}
}
複製代碼
import java.io.Console;
public class ch06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
x=Integer.parseInt(c.readLine("輸入一整數: "));
System.out.println("剛輸入: "+x);
y=Float.parseFloat(c.readLine("輸入一浮點數: "));
System.out.println("剛輸入: "+y);
}
}
複製代碼
作者:
謝宗佑
時間:
2019-7-1 16:01
import java.io.Console;
public class CH06
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數:");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入:"+x);
System.out.print("輸入一浮點數:");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入:"+y);
}
}
複製代碼
作者:
陳柏銓
時間:
2019-7-1 16:13
import java.io.Console;
public class Ch07
{
public static void main(String args[])
{
int x;
float y;
Console c=System.console();
System.out.print("輸入一整數: ");
x=Integer.parseInt(c.readLine());
System.out.println("剛輸入: "+x);
System.out.print("輸入一浮點數: ");
y=Float.parseFloat(c.readLine());
System.out.println("剛輸入: "+y);
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2