1. import javax.management.MalformedObjectNameException;
    2. import java.util.Scanner;
    3. public class Bank {
    4. public String Banker;
    5. public long BankNum;
    6. public double Balance;
    7. public Bank(String man,long num,double money)
    8. {
    9. Banker= man;
    10. BankNum=num;
    11. Balance=money;
    12. }
    13. public double CheckBalance() {
    14. return Balance;
    15. }
    16. public void Deposit(double a) {
    17. Balance+=a;
    18. }
    19. public Boolean Withdrawal(double money) {
    20. if(money>Balance)
    21. return false;
    22. Balance-=money;
    23. return true;
    24. }
    25. public void Operation(){
    26. Scanner In=new Scanner(System.in);
    27. System.out.println(Banker+"先生您好!");
    28. System.out.println("查询余额请按:1 存款请按:2 取款请按:3 结束请按:0");
    29. int select=1;
    30. while(select!=0)
    31. {
    32. select=In.nextInt();
    33. switch (select)
    34. {
    35. case 0:
    36. System.out.println("感谢您的使用!!!");
    37. break;
    38. case 1://查询余额
    39. System.out.println("余额:"+this.CheckBalance());
    40. break;
    41. case 2://存钱
    42. System.out.print("输入存款金额:");
    43. Double a=In.nextDouble();
    44. this.Deposit(a);
    45. break;
    46. case 3://取钱
    47. System.out.print("输入取款金额:");
    48. Double m=In.nextDouble();
    49. Boolean T = this.Withdrawal(m);
    50. if(T)
    51. System.out.println("Withdrawal completed!!!");
    52. else
    53. System.out.println("Insufficient balance!!!");
    54. break;
    55. default:
    56. System.out.println("输入不合法,请重新输入!!");
    57. }
    58. }
    59. }
    60. public static void main(String[] args) {
    61. Bank Banker1=new Bank("张三",1012468689,25415.2651);
    62. Bank Banker2=new Bank("李四",245144654,35694.2651);
    63. Banker1.Operation();
    64. System.out.println("_________________");
    65. Banker2.Operation();
    66. }
    67. }
    1. public class Triangle {
    2. public int A;
    3. public int B;
    4. public int C;
    5. public void Set(int a,int b,int c){
    6. this.A=a;
    7. this.B=b;
    8. this.C=c;
    9. }
    10. public double GetArea(){
    11. double p=(A+B+C)/2;
    12. double Area=Math.sqrt((p*(p-A)*(p-B)*(p-C)));
    13. return Area;
    14. }
    15. public double GetAround() {
    16. return (A+B+C);
    17. }
    18. public static void main(String[] args) {
    19. Triangle t1=new Triangle();
    20. t1.Set(3,4,5);
    21. System.out.println("t1的面积为:"+t1.GetArea());
    22. System.out.println("t1的周长为:"+t1.GetAround());
    23. Triangle t2=new Triangle();
    24. t2.Set(7,8,9);
    25. System.out.println("t2的面积为:"+(String.format("%.4f",t2.GetArea())));
    26. System.out.println("t2的周长为:"+t2.GetAround());
    27. }
    28. }
    1. import java.util.Scanner;
    2. public class Student {
    3. public String No;
    4. public String Name;
    5. public int Age;
    6. //static int num=0;
    7. public Student(String no,String name,int age){
    8. No =no;
    9. Name=name;
    10. Age=age;
    11. }
    12. public void display(){
    13. System.out.print("学号::"+No);
    14. System.out.print(" 姓名::"+Name);
    15. System.out.println(" 年龄::"+Age);
    16. }
    17. public void Addage(){
    18. Age+=1;
    19. }
    20. public static void main(String[] args) {
    21. // Scanner In=new Scanner(System.in);
    22. Student s[]=new Student[5];
    23. s[0]=new Student("001","张三",18);
    24. s[1]=new Student("002","李四",19);
    25. s[2]=new Student("003","王五",20);
    26. s[3]=new Student("004","小明",21);
    27. s[4]=new Student("005","小红",18);
    28. for(int i=0;i<5;i++)
    29. s[i].display();//显示信息
    30. System.out.println("___________________________________");
    31. for(int i=0;i<5;i++)//年龄加1
    32. s[i].Addage();
    33. for(int i=0;i<5;i++)//年龄加1后输出
    34. s[i].display();
    35. System.out.println("_________输出年龄大于20的学生________");
    36. for(int i=0;i<5;i++){//年龄加1后输出
    37. if(s[i].Age>=20)
    38. s[i].display();
    39. }
    40. }
    41. }
    1. import java.util.Scanner;
    2. public class Data {
    3. public int Year;
    4. public int Month;
    5. public int Day;
    6. //
    7. Data(int y,int m,int d){
    8. Year=y;
    9. Month=m;
    10. Day=d;
    11. }
    12. public boolean IsLeapYear()
    13. {
    14. if((Year%4==0&&Year%100!=0)||(Year%400==0))
    15. return true;
    16. return false;
    17. }
    18. public boolean Check(){
    19. if(Month<1||Month>12)
    20. return false;
    21. if((Month==1||Month==3||Month==5||Month==7||Month==8||Month==10||Month==12)&&(Day<1||Day>31))
    22. return false;
    23. if((Month==4||Month==6||Month==9||Month==11)&&(Day<1||Day>30))
    24. return false;
    25. if((Month==2&&this.IsLeapYear())&&(Day<1||Day>29))
    26. return false;
    27. if((Month==2&&(!this.IsLeapYear()))&&(Day<1||Day>28))
    28. return false;
    29. return true;
    30. }
    31. public static void main(String[] args) {
    32. while(true) {
    33. Scanner In=new Scanner(System.in);
    34. int y=In.nextInt();
    35. int m=In.nextInt();
    36. int d=In.nextInt();
    37. Data D=new Data(y,m,d);
    38. if(D.Check())
    39. System.out.println(y+"/"+m+"/"+d);
    40. else
    41. System.out.println("输入不合法");
    42. }
    43. }
    44. }