134-hw

java程序中为了程序正常运行,需要给无限循环加入一个退出选项,保证程序的可执行性。

import java.util.Scanner;
public class View Code {
         public static void main(String[] args) {
                  Scanner scan = new Scanner(System.in);
system.out.println("请输入您的操作选项");
int num = scan.nextInt();
switch (num) { case \'1\':
Scanner scan = new Scanner (System.in); System.out.println(
"请输入用户名:"); int user = scan.nextInt(); System.out.println("请输入密码:"); int password = scan.nextInt(); if(ture&&ture){ System.out.println("登陆成功"); /*继续执行下一步操作*/ }else{ System.out.println("登陆失败,请重新登录"); } case \'2\': system.exit(-1); default: System.out.println("无效的输入,请 重新输入"); }

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2020-03-20
  • 2022-02-15
  • 2022-02-02
  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2018-01-04
  • 2021-12-25
  • 2021-05-31
  • 2022-01-25
相关资源
相似解决方案