一道Java编程题,拜托了
发布网友
发布时间:2023-07-10 11:07
我来回答
共5个回答
热心网友
时间:2024-01-14 02:23
package exam;
public class Test1 {
public static void main(String[] args) {
String NAME = "西海龙王";
int lowage=1998;
int nowage=2016;
int age=Age(lowage,nowage);
System.out.println(NAME+lowage+"年出生,今年"+age+"岁");
}
private static int Age(int i, int j) {
return j-i;
}
}
热心网友
时间:2024-01-14 02:24
package exam
import java.util.Scanner;
public class Test1{
public static void main(String[] args){
String NAME="例如你叫某某";
System.out.println("请输入你的出生年份");
Scanner sc=new Scanner(System.in);
int cyear=sc.nextInt();
System.out.println("请输入当前年份");
int dyear=sc.nextInt();
System.out.println(NAME+cyear+"出生,今年"+(dyear-cyear)+"岁");
}
}
//我直接手打的,有些符号可能中英文不一样,你自己注意改
热心网友
时间:2024-01-14 02:24
package exam;
public class Test1
{
public static void main(String[] args) throws Exception
{
int byear,dyear;
byear=Integer.parseInt(args[0]);
dyear=Integer.parseInt(args[1]);
System.out.printf("%s%d年出生,今年%d岁。",Test1.NAME,byear,(dyear-byear));
}
//修改NAME的值为你的名字
static final String NAME="你的名字";
}
热心网友
时间:2024-01-14 02:25
private static String name="张三";
public static void main(String[] args) {
System.out.println(name+args[0]+"出生,今年"+(Integer.valueOf(args[1])-Integer.valueOf(args[0]))+"岁。");
}
热心网友
时间:2024-01-14 02:25
代码如下:
package exam;
import java.util.Scanner;
public class Test1{
public static void main(String[] args){
String name = "zhangsan";
System.out.println("请输入你的出生年份: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String year = br.readLine();
System.out.println("请输入当前年份:");
String cyear= br.readLine();
System.out.println(name + year +"年出生,今年" + (Integer.valueOf(cyear) - Integer.valueOf(year) + "岁"));
}
}
热心网友
时间:2024-01-14 02:24
package exam;
public class Test1 {
public static void main(String[] args) {
String NAME = "西海龙王";
int lowage=1998;
int nowage=2016;
int age=Age(lowage,nowage);
System.out.println(NAME+lowage+"年出生,今年"+age+"岁");
}
private static int Age(int i, int j) {
return j-i;
}
}
热心网友
时间:2024-01-14 02:24
package exam;
public class Test1 {
public static void main(String[] args) {
String NAME = "西海龙王";
int lowage=1998;
int nowage=2016;
int age=Age(lowage,nowage);
System.out.println(NAME+lowage+"年出生,今年"+age+"岁");
}
private static int Age(int i, int j) {
return j-i;
}
}
热心网友
时间:2024-01-14 02:24
package exam
import java.util.Scanner;
public class Test1{
public static void main(String[] args){
String NAME="例如你叫某某";
System.out.println("请输入你的出生年份");
Scanner sc=new Scanner(System.in);
int cyear=sc.nextInt();
System.out.println("请输入当前年份");
int dyear=sc.nextInt();
System.out.println(NAME+cyear+"出生,今年"+(dyear-cyear)+"岁");
}
}
//我直接手打的,有些符号可能中英文不一样,你自己注意改
热心网友
时间:2024-01-14 02:24
package exam
import java.util.Scanner;
public class Test1{
public static void main(String[] args){
String NAME="例如你叫某某";
System.out.println("请输入你的出生年份");
Scanner sc=new Scanner(System.in);
int cyear=sc.nextInt();
System.out.println("请输入当前年份");
int dyear=sc.nextInt();
System.out.println(NAME+cyear+"出生,今年"+(dyear-cyear)+"岁");
}
}
//我直接手打的,有些符号可能中英文不一样,你自己注意改
热心网友
时间:2024-01-14 02:25
package exam;
public class Test1
{
public static void main(String[] args) throws Exception
{
int byear,dyear;
byear=Integer.parseInt(args[0]);
dyear=Integer.parseInt(args[1]);
System.out.printf("%s%d年出生,今年%d岁。",Test1.NAME,byear,(dyear-byear));
}
//修改NAME的值为你的名字
static final String NAME="你的名字";
}
热心网友
时间:2024-01-14 02:25
package exam;
public class Test1
{
public static void main(String[] args) throws Exception
{
int byear,dyear;
byear=Integer.parseInt(args[0]);
dyear=Integer.parseInt(args[1]);
System.out.printf("%s%d年出生,今年%d岁。",Test1.NAME,byear,(dyear-byear));
}
//修改NAME的值为你的名字
static final String NAME="你的名字";
}
热心网友
时间:2024-01-14 02:25
private static String name="张三";
public static void main(String[] args) {
System.out.println(name+args[0]+"出生,今年"+(Integer.valueOf(args[1])-Integer.valueOf(args[0]))+"岁。");
}
热心网友
时间:2024-01-14 02:26
代码如下:
package exam;
import java.util.Scanner;
public class Test1{
public static void main(String[] args){
String name = "zhangsan";
System.out.println("请输入你的出生年份: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String year = br.readLine();
System.out.println("请输入当前年份:");
String cyear= br.readLine();
System.out.println(name + year +"年出生,今年" + (Integer.valueOf(cyear) - Integer.valueOf(year) + "岁"));
}
}
热心网友
时间:2024-01-14 02:25
private static String name="张三";
public static void main(String[] args) {
System.out.println(name+args[0]+"出生,今年"+(Integer.valueOf(args[1])-Integer.valueOf(args[0]))+"岁。");
}
热心网友
时间:2024-01-14 02:26
代码如下:
package exam;
import java.util.Scanner;
public class Test1{
public static void main(String[] args){
String name = "zhangsan";
System.out.println("请输入你的出生年份: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String year = br.readLine();
System.out.println("请输入当前年份:");
String cyear= br.readLine();
System.out.println(name + year +"年出生,今年" + (Integer.valueOf(cyear) - Integer.valueOf(year) + "岁"));
}
}