赞
踩
现代社会,单位面试都会要求做一个自我介绍,介绍个人的名字、年龄、学历、职位等等。这可让某些人犯了难,聪明的你可以帮助他们写一个可以自我介绍的程序么?
补全下面程序代码段中注释 Begin 至 End 中间的代码,具体要求如下:
-创建一个SelfIntroduction对象,对象名称为person,利用类中已经编写好的方法传入相关的属性,即name(姓名)、age(年龄)、education(学历)、position(职位);
-调用类的方法introduction()输出自我介绍的一句话。
- import java.util.Scanner;
-
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String name = scanner.next();
- int age = scanner.nextInt();
- String education = scanner.next();
- String position = scanner.next();
-
- /********** Begin *********/
-
-
- /********** End *********/
- }
- }
-
- class People {
- private String name;
- private int age;
- private String education;
- private String position;
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public void setEducation(String education) {
- this.education = education;
- }
-
- public void setPosition(String position) {
- this.position = position;
- }
-
- public void introduction() {
- System.out.println("大家好!我是" + name + ",我今年" + age + "岁,"
- + education + "学历," + "目前职位是" + position);
- }
- }
输入一个人的姓名、年龄、学历和职位。
输出自我介绍信息。
- import java.util.Scanner;
-
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String name = scanner.next();
- int age = scanner.nextInt();
- String education = scanner.next();
- String position = scanner.next();
-
- /********** Begin *********/
-
- People person = new People();
- person.setName(name);
- person.setAge(age);
- person.setEducation(education);
- person.setPosition(position);
- person.introduction();
-
- /********** End *********/
- }
- }
-
- class People {
- private String name;
- private int age;
- private String education;
- private String position;
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public void setEducation(String education) {
- this.education = education;
- }
-
- public void setPosition(String position) {
- this.position = position;
- }
-
- public void introduction() {
- System.out.println("大家好!我是" + name + ",我今年" + age + "岁,"
- + education + "学历," + "目前职位是" + position);
- }
- }
张三 35 博士 讲师
大家好!我是张三,我今年35岁,博士学历,目前职位是讲师
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。