人机交互的小作业
(1)Scanner 扫描仪 用于获取"客户"的键盘录入的信息
“找到具体的扫描仪” 创建对象
Scanner input=new Scanner(System.in); //input是自己起的名称
【1】获取int类型的值 input. nextInt();
【2】获取double类型的值 input.nextDouble();
【3】获取String类型的值 input.next();
【4】获取char类型的值 input.next().charAt(0);
import java.util.Scanner; //导包
public class Test05{
public static void main(String[] args){
//找到扫描仪
Scanner input=new Scanner(System.in);
//提示信息
System.out.println("请输入流水号:");
/**从键盘获取一个整数赋值给int类型的变量serial_number 中存储*/
int serial_number=input.nextInt(); //流水号
System.out.println("请输入年龄:");
int age=input.nextInt(); //年龄
System.out.println("专家号还是普通号?专家50普通20");
double registered_fee=input.nextDouble(); //挂号费
double flat_cost=1.00; //工本费
System.out.println("请输入就诊人员姓名:");
String name=input.next();
System.out.println("请输入性别:");
char sex=input.next().charAt(0);
String outpatient="急诊"; //门诊类别
String technicalOffices="脑外科";
String date="2018-2-4";
String worker="李三小";
String workTime="2018-2-4";
System.out.println("\n");
System.out.println("\t武汉\t中医\t");
System.out.println("\t挂号预约凭证\t");
System.out.println(" \t(存根)\t\n");
//System.out.println("\n");
System.out.println("------------------------------------");
System.out.println("流水号:"+serial_number+" 处方号:");
System.out.println("姓名:"+name+" "+"性别:"+sex+" "+"年龄:"+age);
System.out.println("门诊类别:"+outpatient+" "+"科别:"+technicalOffices);
System.out.println("就诊时间:"+date);
System.out.println("挂号费:¥"+registered_fee+" "+"工本费¥:"+flat_cost);
System.out.println("------------------------------------");
System.out.println("挂号员:"+worker+"\t挂号日期:"+workTime);
System.out.println("\n");
}
}