package cn.ALAN_CF.studyf001;
public class Rectangle {
double width = 1;
double height = 1;
Rectangle(){
}
Rectangle(double width,double height) {
this.width = width;
this.height = height;
}
public double getArea(){
return width * height;
}
public double getPerimeter(){
return 2 * (width + height);
}
public static void main(String[] args) {
Rectangle exampleRectangle1=new Rectangle(12.5,16.0);
Rectangle exampleRectangle2 = new Rectangle();
System.out.println("example1.area:" + exampleRectangle1.getArea());
System.out.println("example1.perimeter: "+exampleRectangle1.getPerimeter());
System.out.println("example2.area: "+exampleRectangle2.getArea());
System.out.println("exampleRectangle2.Perimeter: "+exampleRectangle2.getPerimeter());
}
}
package cn.ALAN_CF.studyf001;
import java.util.Scanner;
class Studenttype{
private int id;
private String name;
private int age;
Studenttype (int id,String name,int age) {
this.id = id;
this.name = name;
this.age = age;
}
public void output() {
if(age<7||age>70) {
System.out.print("bad");
}
else {
System.out.print(Integer.toString(id)+' '+name+' '+Integer.toString(age));
}
}
}
public class Student {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int count;
count = Integer.parseInt(input.nextLine());
int id,age;
String name;
String Line;
String[] Line_p = new String[3];
Studenttype[] stu = new Studenttype[count];
for(int i = 0; i < count; i++) {
Line = input.nextLine();
Line_p = Line.split(" ");
id = Integer.parseInt(Line_p[0]);
name = Line_p[1];
age = Integer.parseInt(Line_p[2]);
stu[i] = new Studenttype(id, name, age);
}
for(int i = 0; i < count; i++) {
stu[i].output();
if(i!=count-1) {
System.out.println();
}
}
}
}