Java编程

仿网易云课堂java

StartSMS.javapackage cn.itcast;import java.util.Scanner;/ 系统开启类** @author Administrator**/public class StartSMS {public StartSMS() {}public static void main(String args[]) {Data data = new Data();data.ini();Menu menu = new Menu();menu.setData(data.goodsName, data.goodsPrice, data.custNo,data.custBirth, data.custScore);menu.showLoginMenu();boolean flag = true;label0: do {if (!flag)break;Scanner scanner = new Scanner(System.in);int i = scanner.nextInt();VerifyEqual verifyequal = new VerifyEqual();switch (i) {case 1: // ‘\001’int j = 3;do {if (j < 1)continue label0;if (verifyequal.verify(data.manager.username,data.manager.password)) {menu.showMainMenu();continue label0;}if (j != 1) {System.out.println("\n用户名和密码不匹配,请重新输入:");} else {System.out.println("\n您没有权限进入系统!谢谢!");flag = false;}j--;} while (true);case 2: // '\002'if (verifyequal.verify(data.manager.username,data.manager.password)) {System.out.print("请输入新的用户名:");data.manager.username = scanner.next();System.out.print("请输入新的密码:");data.manager.password = scanner.next();System.out.println("用户名和密码已更改!");System.out.println("\n请选择,输入数字:");} else {System.out.println("抱歉,你没有权限修改!");flag = false;}break;case 3: // '\003'System.out.println("谢谢您的使用!");//flag = false;System.exit(0);break;default:System.out.print("\n输入有误!请重新选择,输入数字: ");break;}} while (flag);}}2 VerifyEqual.javapackage cn.itcast;import java.util.Scanner;/ 验证管理员登录** @author Administrator**/public class VerifyEqual {public VerifyEqual() {}public boolean verify(String s, String s1) {System.out.print("请输入用户名:");Scanner scanner = new Scanner(System.in);String s2 = scanner.next();System.out.print("请输入密码:");scanner = new Scanner(System.in);String s3 = scanner.next();return s2.equals(s) && s1.equals(s3);}}3 CustManagement.javapackage cn.itcast;import java.util.Scanner;public class CustManagement {public CustManagement() {}public void setData(String as[], double ad[], int ai[], String as1[],int ai1[]) {goodsName = as;goodsPrice = ad;custNo = ai;custBirth = as1;custScore = ai1;}public void returnLastMenu() {System.out.print("\n\n请按'n'返回上一级菜单:");Scanner scanner = new Scanner(System.in);boolean flag = true;doif (scanner.next().equals("n")) {Menu menu = new Menu();menu.setData(goodsName, goodsPrice, custNo, custBirth,custScore);menu.showCustMMenu();} else {System.out.print("输入错误, 请重新'n'返回上一级菜单:");flag = false;}while (!flag);}public void add() {System.out.println("购物管理系统 > 客户信息管理 > 添加客户信息\n\n”);Scanner scanner = new Scanner(System.in);System.out.print(“请输入会员号(<4位整数>):”);int i = scanner.nextInt();System.out.print(“请输入会员生日(月/日<用两位数表示>):”);String s = scanner.next();System.out.print(“请输入积分:”);int j = scanner.nextInt();int k = -1;int l = 0;do {if (l >= custNo.length)break;if (custNo[l] == 0) {k = l;break;}l++;} while (true);custNo[k] = i;custBirth[k] = s;custScore[k] = j;System.out.println(“新会员添加成功!”);returnLastMenu();}public void modify() {System.out.println(“购物管理系统 > 客户信息管理 > 修改客户信息\n\n”);System.out.print(“请输入会员号:”);Scanner scanner = new Scanner(System.in);int i = scanner.nextInt();System.out.println(” 会员号 生日 积分 “);System.out.println(“————。

仿网易云课堂java

import java.util.Scanner;public class TriangleArea {public static void main(String[] args) {//输入底和高,计算三角形面积System.out.println(“请输入三角形的底和高:”);Scanner sc=new Scanner(System.in);double s=sc.nextDouble();//底double h=sc.nextDouble();//高double triangleArea=area(s,h);System.out.println(“三角形面积为:”+triangleArea);}public static double area(double a,double b) {return a*b*0.5;}}。

package cn.itcast_01;/** created by yinqanne in 2018/8/30*/import java.util.HashMap;import java.util.Scanner;import java.util.Set;/** 输入一个字符串,找出第一第二个重复的字符* 输入例子1:abcadfscdd* 输出例子1:a b*/public class Test5 {public static void main(String[] args){Scanner sc = new Scanner(System.in);String string = sc.nextLine();int len = string.length();if(string==null。

import java.util.Scanner;public class Test{public static void main(String[] args){Scanner scanner = new Scanner(System.in);System.out.print(“请输入上次考试成绩:”);int grade1 = scanner.nextInt();System.out.print(“请输入本次考试成绩:”);int grade2 = scanner.nextInt();float percent = (float)(grade2 – grade1)/ grade1*100;System.out.printf(“%.2f%%\n”,percent);}}(二)if判断if语句的基本语法是。

———————import java.util.Scanner;public class Month{public static void main(String[] args){Scanner input=new Scanner(System.in);System.out.println(“请你输入一个月份,我来输出季节”);int mon=input.nextInt();//获取数字int mon=input.nextLine();//获取字符串if(mon>=3 & mon<=5){System.out.println("春天");}else if(mon>5 & mon<9){System.out.println("夏天");}else if(mon>8 & mon<12){System.out.println("秋天");}else if(mon==12。

咕泡云课堂,提供JAVA、大数据、人工智能、软件测试等热门的IT技术课程,由咕泡云课堂精心打造,致力于推动每一次人才升级。

Similar Posts

发表评论

邮箱地址不会被公开。 必填项已用*标注