请帮助我的程序我对编码有点新,我不知道如何解决我的问题。代码工作没有错误,但结果错误。我在几天内写作考试,希望得到一些帮助。
package Practice1.pkg1;
import java.time.Year;
import java.util.Scanner;
public class Sub1 {
public static void main(String[] args) {
int age = 0;
String name ="";
String surname ="";
int dob = 0;
int year = Year.now().getValue();
info( name, sur**strong text**name, age);
calc(age, year, dob);
result(name, surname, age, year, dob);
}
public static void info(String name, String surname, int age) {
System.out.println("What is your name user?");
Scanner input= new Scanner(System.in);
name = input.nextLine();
System.out.println("What is your surname user?");
Scanner input2= new Scanner(System.in);
surname = input2.nextLine();
System.out.println("What is your age user?");
Scanner input3= new Scanner(System.in);
age = Integer.parseInt(input3.nextLine());
}
public static void calc(int age, int year, int dob) {
dob = year - age;
}
public static void result(String name, String surname, int age, int year, int dob) {
System.out.println("Welcome "+name+" "+ surname+" born in "+dob);
//user in put returns back to default.
}
}