scannerクラスの入出力

6181 ワード

package java_program;
import java.util.Scanner;
public class input_out {

	public input_out() {
		// TODO Auto-generated constructor stub
	}
	public static void main(String[] args)
	{
		String message;
		
		//         :
		Scanner scan = new Scanner (System.in);
		
		System.out.println("please enter the words");
		message = scan.nextLine();
		
		System.out.println(" you  entered the words:" + message);
		
	}

}

限定された特殊な変数を入力します.
package java_program;

import java.util.Scanner;
public class out_bim {
	public static void main(String[] args)
	{
		String name ;
		double age , weight,height;
		double bim;
		Scanner scan= new Scanner(System.in);
		System.out.println("please enter the name:");
		name = scan.next();
		
		System.out.println(" please enter your age");
		age = scan.nextInt();
		
		System.out.println("please enter your weight :");
		weight = scan.nextInt();
		
		System.out.println("please enter your heiht: ");
	    height =  scan.nextInt();
		
		bim = (weight+height)/10;
		System.out.println(" your bim:"+bim);
		
	}
}