java入门编程作业,求大神给程序,谢谢
3个回答
展开全部
public static void t1 () {
Scanner sc = new Scanner(System.in);
System.out.print("请输入你的姓名:");
String name = sc.next();
System.out.print("请输入你的性别:");
String sex = sc.next();
System.out.print("请输入你的年龄:");
int age = sc.nextInt();
System.out.println("姓名\t性别\t年龄\n" + name + "\t" + sex + "\t" + age);
}
public static void t2 () {
Scanner sc = new Scanner(System.in);
System.out.print("请输入一个整数:");
int num = sc.nextInt();
System.out.println("1 * " + num + " = " + (1 * num));
System.out.println("2 * " + num + " = " + (2 * num));
System.out.println("3 * " + num + " = " + (3 * num));
System.out.println("4 * " + num + " = " + (4 * num));
System.out.println("5 * " + num + " = " + (5 * num));
}
展开全部
import java.util.Scanner;
public class Test1 {
private static String name;
private static String sex;
private static int age;
private static Scanner sc;
public static void main(String[] args){
System.out.print("请输入你的姓名:");
sc = new Scanner(System.in);
name = sc.nextLine();
System.out.print("请输入你的性别:");
sc = new Scanner(System.in);
sex = sc.nextLine();
System.out.print("请输入你的年龄:");
sc = new Scanner(System.in);
String ageStr = sc.nextLine();
try{
age = Integer.parseInt(ageStr);
}catch(Exception e){
}
System.out.println("姓名 性别 年龄");
System.out.println(name+" "+sex+" "+age);
}
}
import java.util.Scanner;
public class Test2 {
public static void main(String[] args){
System.out.print("请输入一个整数:");
Scanner sc = new Scanner(System.in);
String iStr = sc.nextLine();
try{
int i = Integer.parseInt(iStr);
for(int n=1;n<=5;n++){
System.out.println(i+"*"+n+"="+i*n);
}
}catch(Exception e){
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public void printSth(){
Scanner s= new Scanner(System.in);
System.out.println("请输入姓名:");
String name=s.nextLine();
System.out.println("请输入性别:");
String sex=s.nextLine();
System.out.println("请输入年龄:");
int age=s.nextInt();
System.out.println("姓名"+"\t"+"性别"+"\t"+"年龄");
System.out.println(name+""+"\t"+sex+"\t"+age);
s.close();
}
public void pirntInt(){
Scanner s= new Scanner(System.in);
System.out.println("请输入一个整数:");
int x=s.nextInt();
for (int i = 1; i < 6; i++) {
System.out.println(i+"*"+x+"="+i*x);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询