我第一次来这里,请不要评价我
我可以帮助说出我必须使用哪种陈述,以便我的代码回到主要问题? (见代码)
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("What is your name? "); // Line A
String name = scan.nextLine();
System.out.println("Entered name: " + name);
System.out.println();
switch (name) {
case "Sam":
System.out.println("aaa!");
break; // from here it must to Line A
case "Michael":
System.out.println("bbb!");
break; // from here it must to Line A
case "Arnold":
System.out.println("ccc!");
break; // from here it must to Line A
default:
System.out.println("Try again!");
}
} /* and when it executes 3 times with correct answer,
it must go to the final line approx."Thank you" */
}
答案 0 :(得分:3)
您可能希望添加一个索引整数,该整数将随每个正确答案而增加,可能会执行类似这样的操作
[HttpPost]
public ActionResult Record(string name)
{
//code for what needs to be performed.
return View();
}
此代码使用do while循环,它将在检查布尔语句是真还是假之前重复其中的代码一次。如果是,则代码将重复,如果为false,则代码不会重复。希望这会有所帮助。