public class XXX{
public static void main(String[] args){
double avg=13.2;
int avg1=(int)avg;
System.out.println(avg);
system.out.println(avg1);
}
}
public static void main(String[] args){
double avg=13.2;
int avg1=(int)avg;
System.out.println(avg);
system.out.println(avg1);
}
}
2015-07-08
public class HelloWorld{
public static void main(String[] args){
String city;
city="神去村";
System.out.println("我的家乡在"+city);
}
}
public static void main(String[] args){
String city;
city="神去村";
System.out.println("我的家乡在"+city);
}
}
2015-07-08
String[] hobbys = { "sports", "game", "movie" };
System.out.println("循环输出数组中元素的值:");
// 使用循环遍历数组中的元素
int i=0;
for(i=0;i<=hobbys.length-1;i++){
System.out.println(hobbys[i]);
}
System.out.println("循环输出数组中元素的值:");
// 使用循环遍历数组中的元素
int i=0;
for(i=0;i<=hobbys.length-1;i++){
System.out.println(hobbys[i]);
}
2015-07-07
public class HelloWorld{
public static void main(String[] args){
int num = 999;
int count = 0;
while(num!=0)
{
num/=10;
count++;
}
System.out.println("它是个"+count+"位的数!");
}
}
public static void main(String[] args){
int num = 999;
int count = 0;
while(num!=0)
{
num/=10;
count++;
}
System.out.println("它是个"+count+"位的数!");
}
}
if(age>60){
System.out.println("老年");
}else if(age>40){
System.out.println("中年");
}else if(age>18){
System.out.println("少年");
}else{
System.out.println("童年");
}
System.out.println("老年");
}else if(age>40){
System.out.println("中年");
}else if(age>18){
System.out.println("少年");
}else{
System.out.println("童年");
}
2015-07-06
public static void main(String[] args) {
System.out.println("打印直角三角形");
// 外层循环控制行数
for (int i = 1; i<=4;i++ ) {
for (int j = 1;j<i;j++) {
System.out.print("*");
}
// 每打印完一行后进行换行
System.out.println();
}
}
System.out.println("打印直角三角形");
// 外层循环控制行数
for (int i = 1; i<=4;i++ ) {
for (int j = 1;j<i;j++) {
System.out.print("*");
}
// 每打印完一行后进行换行
System.out.println();
}
}
2015-07-06