猜年龄
冒泡排序
//冒泡排序
int[] number= {15,75,69,25,105,420,77};
for(int i=0;i<number.length-1;i++){
for(int j=0;j<number.length-1;j++){
if(number[j]>number[j+1]) {
int temp;
temp=number[j];
number[j]=number[j+1];
number[j+1]=temp;
}
}
}
for(int i=0;i<number.length;i++) {
System.out.println(number[i]);
}
消费单
//声明变量数目
int tShirt_num,shose_num,pad_num;
//声明变量价格
int tShirt_price,shose_price,pad_price;
//总价
int total;
//从控制台输入
Scanner sc=new Scanner(System.in);
System.out.println("请输入T桖数量");
tShirt_num=sc.nextInt();
System.out.println("请输入网球鞋数量");
shose_num=sc.nextInt();
System.out.println("请输入网球拍数量");
pad_num=sc.nextInt();
System.out.println("请输入T桖价格");
tShirt_price=sc.nextInt();
System.out.println("请输入网球鞋价格");
shose_price=sc.nextInt();
System.out.println("请输入网球拍价格");
pad_price=sc.nextInt();
System.out.println("******消费单*******");
System.out.println("购买物品\t单价\t个数\t金额");
System.out.println("T桖\t"+tShirt_price+"\t"+tShirt_num+"\t"+tShirt_num*tShirt_price);
System.out.println("T桖\t"+shose_price+"\t"+shose_num+"\t"+shose_num*shose_price);
System.out.println("T桖\t"+pad_price+"\t"+pad_num+"\t"+pad_num*pad_price);
total=tShirt_num*tShirt_price+shose_num*shose_price+pad_num*pad_price;
System.out.println("****************");
System.out.println("总价:\t"+total);