输入自己的名字,年龄和性别,分别用不同的变量接收,并将输入的信息做输出
package work;
import java.util.Scanner;
public class Introduction {
public static void main(String[] args) {
//创建对象
Scanner sc =new Scanner(System.in);
System.out.print("请输入圆的半径:");
double radius = sc.nextDouble();
System.out.println("该圆的半径为:" + "R=" + radius);
System.out.println("该圆的周长为:" + "C=" + "2"+"*"+"3.14"+"*"+radius + "="+ 2*3.14*radius);
System.out.println("该圆的面积为:" + "S=" + "3.14" +"*"+radius + "*"+radius+"="+ 3.14*radius*radius);
}
}
输入圆形半径,求圆形的周长和圆形的面积,并将结果输出
package work;
import java.util.Scanner;
public class homework1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入你的名字:");
String name =sc.next();
System.out.println("请输入你的年龄:");
int age = sc.nextInt();
System.out.println("请输入你的性别:");
char xingbie = sc.next().charAt(0);
System.out.println("the computer recorded that:");
System.out.println("your name is:" + name);
System.out.println("your age is:" + age);
System.out.println("your xingbie is:" + xingbie);
}
}