第一步:输入姓名 第二步:选择学历 第三步:确认信息并提交 第四步:提交成功页面的Java代码
时间: 2024-05-06 22:19:44 浏览: 16
这是一个简单的Java代码示例,用于实现提交成功页面:
```java
import java.util.Scanner;
public class SubmitSuccessPage {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// 第一步:输入姓名
System.out.println("请输入您的姓名:");
String name = scanner.nextLine();
// 第二步:选择学历
System.out.println("请选择您的学历:");
System.out.println("1. 初中");
System.out.println("2. 高中");
System.out.println("3. 本科");
System.out.println("4. 硕士");
System.out.println("5. 博士");
int education = scanner.nextInt();
// 第三步:确认信息并提交
System.out.println("请确认您的信息:");
System.out.println("姓名:" + name);
System.out.println("学历:" + getEducationString(education));
System.out.println("是否确认提交?(Y/N)");
String confirm = scanner.next();
if (confirm.equalsIgnoreCase("Y")) {
// 第四步:提交成功页面
System.out.println("提交成功!");
} else {
System.out.println("提交已取消。");
}
}
// 将教育程度的数字转换为字符串
private static String getEducationString(int education) {
switch (education) {
case 1:
return "初中";
case 2:
return "高中";
case 3:
return "本科";
case 4:
return "硕士";
case 5:
return "博士";
default:
return "未知";
}
}
}
```
运行程序后,用户将依次输入姓名、选择学历、确认信息并提交,最终会看到提交成功页面的提示信息。这个程序的逻辑非常简单,但可以作为一个基础的代码框架,供开发者根据实际需求进行修改。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)