如图,做出图中第6题。谢谢………………………………………………………………
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner mScan = new Scanner(System.in);
System.out.println("输入");
String str = null;
do{
str = mScan.next();
if(str.equals("boy")){
System.out.println("帅哥");
}else if(str.equals("girl")){
System.out.println("美女");
}else{
if(!str.equals("over"))
System.out.println("你想什么呢");
}
}
while(!str.equals("over"));
System.out.println("退出程序");
}
Scanner in = new Scanner(System.in);
String str = "";
while (!str.equals("over"))
{ str = in.nextLine();
if (str.equals("girl")) System.out.println("美女");
else if (str.equals("boy")) System.out.println("帅哥");
else System.out.println("你在想什么");
}
import java.util.Scanner;
Scanner in = new Scanner(System.in);
String str = "";
while (!"over".equals(str))
{ str = in.nextLine();
if ("girl".equals(str)) System.out.println("美女");
else if ("boy".equals(str)) System.out.println("帅哥");
else System.out.println("你在想什么");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println("输入");
String str = null;
do{
str = scan.next();
if(str.equals("boy")){
System.out.println("帅哥");
}else if(str.equals("girl")){
System.out.println("美女");
}else{
if(!str.equals("over"))
System.out.println("你想什么呢");
}
}
while(!str.equals("over"));
System.out.println("再见");
}
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
String str="";
do{
str=s.nextLine();
if(str.equals("gril")){
System.out.println("美女");
}else if(str.equals("boy")){
System.out.println("帅哥");
}else {
System.out.println("你在想什么?");
}
}while(!str.equals("over"));
System.out.println("退出程序");
}