java·第三次作业
import java.util.Scanner;
class Pig{
int weight;
static int totalWeight=0;
static int totalNum=0;
void add(int weight){
this.weight=weight;
Pig.totalNum++;
Pig.totalWeight+=this.weight;
}
static int getNum(){
return totalNum;
}
static int getWeight(){
return totalWeight;
}
}
class Main {
public static void main(String args[]){
Scanner ss=new Scanner(System.in);
Pig pp=new Pig();
while(ss.hasNext()){
int x=ss.nextInt();
pp.add(x);
}
System.out.println(Pig.totalNum);
System.out.println(Pig.totalWeight);
}
}