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