1,
纸牌互换简单编程
public class Game {
public static void main(String[] args) {
Scanner input= newScanner(System.in);
System.out.println("输出互换前手中的纸牌:");
System.out.println("左手中的纸牌:");
int cardLeft = input.nextInt( );
System.out.println("右手中的纸牌");
int cardRight=input.nextInt( );
System.out.println("输出互换后手中的纸牌:");
int card =cardLeft+ cardRight; //赋值纸牌个数;
int cardLeft1=card-cardLeft; //纸牌互换;
int cardRight1=card-cardRight;
System.out.println("左手中的纸牌:"+cardLeft1);
System.out.println("右手中的纸牌:"+cardRight1);
}
}
2,华氏温度与摄氏温度转换简单编程
public class Tem {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("华氏温度:");
int fahrenheit = input.nextInt();
double celsius =5/9.0* (fahrenheit-32);
System.out.println("摄氏温度:"+celsius);
}
}
3,银行利息
public class principal {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入本金:");
double money = input.Doule()double interes1=money*0.0225; //银行利息计算;
double interes2=money*0.027*2;
double interes3=money*0.0324*3;
double interes5=money*0.036*5;
System.out.println("本金为:"+money);
System.out.println("存取一年后的本息是:"+(money+interes1)); //本息等于本金加利息;
System.out.println("存取两年后的本息是:"+(money+interes2));
System.out.println("存取三年后的本息是:"+(money+interes3));
System.out.println("存取五年后的本息是:"+(money+interes5));
}
}