/* import java.util.Scanner; */ /*一行书 奇数升序排列 偶数降序排列*//* public class Work { public static void main(String[] args) { int[] a = new int[10], b = new int[10], c = new int[10]; Scanner input = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.println("请您输入一个数"); a[i] = input.nextInt(); if (a[i] % 2 == 0) { b[i] = a[i]; } else { c[i] = a[i]; } } System.out.print("偶数为" ); for (int d : b) { System.out.print( + d); } System.out.print("奇数为"); for (int f : c) { System.out.print( + f); } } } */ /*创建一个二维的整型数组,奇数行升序排列,偶数行降序排列,遍历并打印这个二维数 组*/ /*public class Work { public static void main(String[] args) { int[][] arr = new int [][]{{1,2,3,6,5,},{2,6,8,1,9},{5,4,9,2,7},{1,2,8,5,9},{9,5,8,6,1}}; int max=0; for (int i = 0; i<5; i++) { if (i % 2 == 0) { for (int j = 0; j < 4; j++) { for (int k = 0; k <4 ; k++) { max = arr[i][j]; if (arr[i][j] < arr[i][j + 1]) { arr[i][j] = arr[i][j + 1]; arr[i][j + 1] = max; } } } } else { for (int j = 0; j < 4; j++) { for (int k = 0; k < 4; k++) { max = arr[i][j]; if (arr[i][j] > arr[i][j + 1]) { arr[i][j] = arr[i][j + 1]; arr[i][j + 1] = max; } } } } } for (int i = 0; i <5 ; i++) { if (i%2==0) { System.out.println(); } for (int j = 0; j <5; j++) { System.out.print(arr[i][j]); if (i%2==0) { System.out.println(); } } } } }*/ /*1、一个景区根据游人的年龄收取不同价格的门票。请编写游人类,根据年龄段决定能够 购买的门票价格并输出 2、模拟实现用户密码管理:输入旧的用户名和密码,如果正确,方有权限更新;从键盘 获取新的密码,进行更新 3、模拟实现银行的业务 1、用户登录(三次失败则退出) 2、存款 3、取款(余不足将提示) 4、再次实现昨天手机 销售的例子,数组当中保存的是手机类的对象*/ /* 1、一个景区根据游人的年龄收取不同价格的门票。请编写游人类,根据年龄段决定能够 购买的门票价格并输出*/ /* import java.util.Scanner; class People{ String name; int age; int price=0; public void Price() { if(0<age&&age<=10){ price=0; System.out.println(name+"您需要交纳的费用是:" + price); } if(10<age&&age<=20){ price=10; System.out.println(name+"您需要交纳的费用是:" + price); } if(20<age&&age<=50){ price=20; System.out.println(name+"您需要交纳的费用是:" + price); } if(50<age&&age<=100){ price=10; System.out.println(name+"您需要交纳的费用是:" + price); } if(100<age&&age<1000){ price=0; System.out.println(name+"您需要交纳的费用是:" + price); } } } public class Work { public static void main(String[] args) { Scanner input = new Scanner(System.in); People people = new People(); System.out.println("请输入您的年龄"); people.age= input.nextInt(); System.out.println("请输入您的姓名"); people.name= input.next(); people.Price(); } } */ /*2、模拟实现用户密码管理:输入旧的用户名和密码,如果正确,方有权限更新;从键盘 获取新的密码,进行更新*/ /* import java.util.Scanner; class Jurisdiction{ String zhanghao; String mima; String jiuzhanghao="wzk"; String jiumima="123"; String xinmima; public void Matching() { Scanner input = new Scanner(System.in); if(zhanghao.equals(jiuzhanghao)&&mima.equals(jiumima)) { System.out.println("账号密码正确:您有权限更新您的密码,请输入您的新密码"); xinmima= input.next(); System.out.println("恭喜您您修改成功您的密码,您的密码是"+xinmima); } else if (!mima.equals(jiumima)&&!zhanghao.equals(jiuzhanghao)) { System.out.println("您输入的账号和密码有问题"); } else if (!zhanghao.equals(jiuzhanghao)){ System.out.println("您输入的账号有问题"); } else if (!mima.equals(jiumima)) { System.out.println("您输入的密码有问题"); } } } public class Work { public static void main(String[] args) { Scanner input = new Scanner(System.in); Jurisdiction jurisdiction = new Jurisdiction(); for (int i = 0; i < 3; i++) { System.out.println("请输入您的账号"); jurisdiction.zhanghao= input.next(); System.out.println("请输入您的密码"); jurisdiction.mima= input.next(); jurisdiction.Matching(); } } }*/ /* 3、模拟实现银行的业务 1、用户登录(三次失败则退出) 2、存款 3、取款(余不足将提示) 4、再次实现昨天手机 销售的例子,数组当中保存的是手机类的对象*/ import java.util.Scanner; class Business { int i; int a=10000; int b; public int add() { return a + b; } public int jianf() { return a - b; } public void yunsuan() { if (i==1){ System.out.println("存款结果是:" + add()); } if (i==0){ System.out.println("取款结果是:" + jianf()); } } } public class Work { public static void main(String[] args) { String zhanghao; String mima; String jiuzhanghao="wzk"; String jiumima="123"; int i=2; Scanner input = new Scanner(System.in); for (int j= 0; j<3 ; j++) { System.out.println("请输入您的账号"); zhanghao= input.next(); System.out.println("请输入您的密码"); mima= input.next(); if(zhanghao.equals(jiuzhanghao)&&mima.equals(jiumima)) { System.out.println("账号密码正确"); Business business=new Business(); System.out.println("请您输入您要办的业务"); i= input.nextInt(); if (i==1){ System.out.println("请您输入您要存入的金钱数额"); i= business.yunsuan();} if (i==0){ System.out.println("请您输入您要去除的金钱数额"); business.yunsuan();} break; } if (!mima.equals(jiumima)&&!zhanghao.equals(jiuzhanghao)) { System.out.println("您输入的账号和密码有问题"); } else if (!zhanghao.equals(jiuzhanghao)){ System.out.println("您输入的账号有问题"); } else if (!mima.equals(jiumima)) { System.out.println("您输入的密码有问题"); } } } }