当前位置: 首页 > news >正文

优化网站制作方法大全团购汽车最便宜的网站建设

优化网站制作方法大全,团购汽车最便宜的网站建设,html教程电子书,做一个交易网站多少钱学习第十天#xff0c;发一个总结帖#xff01; 1.基本数据类型#xff0c;变量 基本数据类型不用过多赘述#xff0c;其在后面不论是面型对象还有其他知识等都会经常使用#xff1b; 变量最重要的就是其定义#xff1a; 这对于我们之后理解自定义类型变量有很大的用处…学习第十天发一个总结帖 1.基本数据类型变量 基本数据类型不用过多赘述其在后面不论是面型对象还有其他知识等都会经常使用 变量最重要的就是其定义 这对于我们之后理解自定义类型变量有很大的用处因为这两种类型的变量定义方式差不多学习起来有连贯性。 2.scanner和if循环 scanner 需要导入包使用 static Scanner sc new Scanner(System.in)可以定义在全局sc.next定义在具体位置 iffor循环 iffor中最重要的两点我认为是循环条件以及循环的跳出 循环的条件一般通过具体情况判断 无限循环一般内部是某一模块的开始界面以便于该模块的子模块执行完跳回当然循环嵌套不宜太多。 循环的跳出可以使用break、添加for(;;)或whileture、a:for()breaka等。 但是结构有好还得是设置FLAG 1.不用增添过多的循环层数 2.可以针对for循环内不可以使用if--else结构的特性实现循环内的不同条件选择执行 3.可以有效地避免程序执行顺序问题。 3.数组 数组是学习自定义数据之前很重要的铺垫可以通过自定义数据类型实现的一般都可以通过数组实现只是量的区别 数组循环就可以实现最基本的数仓功能。 数仓案例 import java.util.Scanner;public class DataManager {public static void main(String[] args) {//数据加载很多数---Java如何存数据---java知识点------变量 和 数组----数组---数组的定义格式double[] datas new double[200];for (;;){System.out.println(------------------欢迎来到数据管理系统--------------------);System.out.println(1:查看数据);System.out.println(2:修改数据);System.out.println(3:添加数据);System.out.println(4:删除数据);System.out.println(5:退出系统);System.out.print(请选择1----5);Scanner scanner new Scanner(System.in);int num scanner.nextInt();if (num 1){int temp 0;for (int i 0;i datas.length;i){if (datas[i] !0.0){temp;System.out.println(数仓的数据有:datas[i]);}//如果上面一次都没进意味着没有数据if (temp0){System.out.println(该数仓没有数据请先完成添加);break;}}} else if (num 2) {System.out.print(请输入要修改的数据);int updateid scanner.nextInt();for (int i 0;idatas.length;i){if (datas[i] updateid){//提醒用户输入新的数据System.out.print(请输入新的数据);datas[i] scanner.nextInt();System.out.println(您已修改成功);break;}}} else if (num 3) {System.out.print(请输入要添加的数据:);int newdata scanner.nextInt();//查询操作 遍历数组找到为0.0的位置 22 22for (int i 0;idatas.length;i){if (datas[i]0.0){//该位置为空//插入数据datas[i] newdata;System.out.println(您已添加成功);break;//只允许每次只能插入一个}}} else if (num 4) {//开关 开int flag 1;System.out.print(请输入要删除的数据);int deleteid scanner.nextInt();for (int i 0;i datas.length;i){// 12 22if (deleteid datas[i]){datas[i] 0.0;flag 2;System.out.println(您已删除成功);break;}}if (flag1){System.out.println(删除失败);}} else if (num 5) {System.out.println(您已成功退出);//结束程序System.exit(0);}}} }4.方法 定义方法时不要考虑是我该定义有返回值还是无返回值因为当我们调用该方法时我们需要用值时自然会知道 还是三板斧 编写方法三点 1.我要干什么---决定方法体 2.need什么东西才能干成---决定形式参数 3.是否需要返回调用处---决定是否需要返回值及其类型 阶段测试学生测试系统 package text; import java.util.Scanner; public class text {static Scanner sc new Scanner(System.in);static int flag0;static String [] nameListnew String[100];static String [] pwListnew String [100];static int flag10;public static void main(String[] args) {String stuName 123;String stuPw 123;for (;flag10;){System.out.println(在线考试练习系统);System.out.println(输入数字选择1.练题模式2.注册(3.退出));int num sc.nextInt();dengluxitong(stuName, stuPw, num);}}private static void dengluxitong(String stuName, String stuPw, int num) {if (num 1){System.out.println(练题模式);loginmodel(stuName, stuPw);} else if (num 2) {System.out.println(请输入账号);String zhucename sc.next();for (int i 0; i nameList.length; i) {if (nameList[i]null){nameList[i]zhucename;System.out.println(请输入密码);String zhucepw sc.next();pwList[i] sc.next();break ;}}}tuichumodel(num);}private static void loginmodel(String stuName, String stuPw) {for (;flag0;){System.out.println(请登录);System.out.println(请输入账号);String na sc.next();System.out.println(请输入密码);String pw sc.next();if (na.equals(stuName)pw.equals(stuPw)){flag 1;for (;;){System.out.println(练习题模块);System.out.println(1.水仙花 2。计算分数 3.计算偶数的和 4.偶数奇数 5.打印星星 6.退出 );int choice sc.nextInt();if (choice1){shiuxianhuashu();}if (choice2){System.out.println(任意输入五个人成绩打印输出总分平均分);zongchengjipingjunchengji();}if (choice3){System.out.println(for循环计算100内所有偶数和);oushuhe();}if (choice4){System.out.println(0-45所有奇偶数字个数及其对应的和);jiougeshuhetongji();}if (choice5){System.out.println(打印星星);xingxing();}if (choice6){System.out.println(退出);break ;}}//习题模块}if (flag0){System.out.println(账号或密码错误请重新登录);}}}private static void xingxing() {for (int i 0; i 8; i) {for (int j 0; j i1; j) {System.out.print(*);}System.out.println();}}private static void jiougeshuhetongji() {int countou0;int countji0;int sumou0;int sumji0;for (int i 0; i 45; i) {if (i%20){sumoui;countou;} else if (i%2!0) {sumjii;countji;}}System.out.println(偶数个数为countou);System.out.println(偶数和为sumou);System.out.println(奇数个数为countji);System.out.println(奇数和为sumji);}private static void oushuhe() {int sum0;for (int i 0; i 100; i) {if (i%20){sumi;}}System.out.println(sum);}private static void zongchengjipingjunchengji() {int [] arry new int[5];int sum 0;for (int i 0; i arry.length; i) {System.out.println(请输入第(i1)个成绩);int chengji sc.nextInt();arry[i]chengji;sumchengji;}System.out.println(总成绩sum);System.out.println(平均成绩sum/5);}private static void shiuxianhuashu() {System.out.println(任意输入三个数判断是否是水仙花数);System.out.println(请输入一个三位数);int shuixianhuashusc.nextInt();if(Math.pow(shuixianhuashu % 10, 3) Math.pow(shuixianhuashu / 10 % 10, 3) Math.pow(shuixianhuashu / 100 % 10, 3) shuixianhuashu){System.out.println(shuixianhuashu是水仙花数);}else {System.out.println(shuixianhuashu不是水仙花数);}}private static void tuichumodel(int num) {if (num 3){System.out.println(退出);flag11;}} } 5.自定义数据类型 1.基本定义 2.数据图 1.我们为什么要定义基本数据类型 基本数据类型在存储数据时相当于是数组的集合我们可以看到在Student中原本需要三个数组存储的数据变成了三个属性id那么age 2.关于空间 arr是在main中定义的存储Student类型数据的数组这个行为在栈中开辟了一块空间用来存储arr数组其中每个位置没有数据前都是null 下文Student  a1 new Student()也是同样的道理不过a1数据是Student类的每个a1都包括三个基本属性其中的默认值是各自数据类型的默认值。 3.赋值 从表面看不论是arr还是a1、a2都是在main也就是堆中但是main中只存储了他们的栈中的地址访问时并不能直接在main中找到他们存储的数据。 arr[0]a1看似是赋值操作其实是在arr[0]中存储了a1的地址这样之后使用a[0]时就可以直接根据地址的访问 6.连接数据库 1.sql基本操作 creata  database  test ; drop  database  test ; 创建新表 create table ceshi(   ids int auto_increment primary key,   uid varchar(20),   name varchar(20),   class varchar(20),   foreign key(class) references class(code)   ); CREATE TABLE 表名称     (     列名称1 数据类型,     列名称2 数据类型,     列名称3 数据类型,     )   表操作 1. SELECT 列名称 from 表名称 2. INSERT INTO table_name(列1,列2,...) VALUES(值1,值2,...) 3 .UPDATE 表名称 set 列名称 新值     WHERE 列名称 某值 4. DELETE FROM 表名称 WHERE 列名称 值 2.java链接数据库操作 1.Class.forName(com.mysql.cj.jdbc.Driver); // 加载MySQL JDBC驱动2.Connection con DriverManager.getConnection(jdbc:mysql://127.0.0.1:3306/db1?serverTimezoneUTCcharacterEncodingutf8useUnicodetrueuseSSLfalse,root,123456); // 使用DriverManager获取数据库连接3.Connection con getConnection(); // 获取数据库连接 4.PreparedStatement ps con.prepareStatement(sql) // 创建PreparedStatement对象 5.书写操作及占位符插入举例 PreparedStatement ps con.prepareStatement(insert into shoping (id,name,count,price) values(?,?,?,?)); // 创建PreparedStatement对象 ps.setInt(1,id); ps.setString(2,name); ps.setInt(3,count); ps.setInt(4,price); ps.execute(); System.out.println(插入成功); ps.按照占位符数据种类书写1对应id,以此类推 小案例 aboutdb1; import java.sql.*; import java.util.Scanner; public class newDBsystem {private static Connection getConnection() throws Exception {Class.forName(com.mysql.cj.jdbc.Driver); // 加载MySQL JDBC驱动Connection con DriverManager.getConnection(jdbc:mysql://127.0.0.1:3306/db1?serverTimezoneUTCcharacterEncodingutf8useUnicodetrueuseSSLfalse,root,123456);// 使用DriverManager获取数据库连接return con;}static Scanner scnew Scanner(System.in);//main主类控制执行顺序public static void main(String[] args)throws Exception {while (true){System.out.println(数仓管理系统);System.out.println(1.增 2.删 3.改 4.查 5.退出 );int number sc.nextInt();if (number1){addmodel();}if (number2){delmodel();}if (number3){updatamodel();}if (number4){checkmodel();}if (number5){break;}}}//添加功能public static void addmodel() throws Exception {Connection con getConnection();System.out.println(插入界面);System.out.print(id:);int id sc.nextInt();System.out.print(name:);String name sc.next();System.out.print(count:);int count sc.nextInt();System.out.print(price:);int price sc.nextInt();PreparedStatement ps con.prepareStatement(insert into shoping (id,name,count,price) values(?,?,?,?));// 创建PreparedStatement对象ps.setInt(1,id);ps.setString(2,name);ps.setInt(3,count);ps.setInt(4,price);ps.execute();System.out.println(插入成功);}//查看功能public static void checkmodel() throws Exception {Connection con getConnection();String sql SELECT * FROM shoping;PreparedStatement ps con.prepareStatement(sql);ResultSet rs ps.executeQuery();System.out.println();while (rs.next()) { // 遍历结果集// 使用rs.getXXX(columnName)方法获取每一列的值并打印出来System.out.println(ID: rs.getInt(id) , Name: rs.getString(name) , count: rs.getInt(count) , price: rs.getInt(price));}ps.execute();System.out.println();}//删除功能public static void updatamodel() throws Exception {Connection con getConnection();System.out.println(修改界面);infoidname();System.out.print(请输入所要删除的数据对应id以及其他字段想要修改的值);System.out.print(id:);int id sc.nextInt();System.out.print(其他字段的值);System.out.print(name:);String name sc.next();System.out.print(count:);int count sc.nextInt();System.out.print(price:);int price sc.nextInt();PreparedStatement ps con.prepareStatement(update shoping set name ?,count ?,price? where id?);ps.setString(1,name);ps.setInt(2,count);ps.setInt(3,price);ps.setInt(4,id);int ips.executeUpdate();if (i0){System.out.println(修改成功);}}//修改功能public static void delmodel() throws Exception {Connection con getConnection();System.out.println(删除界面);System.out.print(请输入所要删除的数据对应id);int id sc.nextInt();PreparedStatement ps con.prepareStatement(delete from shoping where id ?);ps.setInt(1,id);ps.execute();System.out.println(删除成功);}//查看id及namepublic static void infoidname() throws Exception {Connection con getConnection();System.out.println(id及名称列表);PreparedStatement pscon.prepareStatement(select id from shoping);ResultSet resultSet ps.executeQuery();while (resultSet.next()){System.out.print(id:resultSet.getInt(id));System.out.print( );}System.out.println();PreparedStatement ps1con.prepareStatement(select name from shoping);ResultSet resultSet1 ps1.executeQuery();while (resultSet1.next()){System.out.print(name:resultSet1.getString(name));System.out.print( );}System.out.println();} 数据库部分不全以后会补充
http://www.zqtcl.cn/news/572750/

相关文章:

  • 西安网站制作排名网站建设对企业的帮助
  • lamp网站开发 pdf纯html5 网站
  • 白云区同和网站建设购物网站怎么建立
  • 公司制作网站需要espcms易思企业网站管理系统
  • 开发一个网站需要哪些步骤广西建设主管部门网站
  • 网站建设培训西安制作微信小程序开发
  • delphi 做直播网站wordpress 商务
  • 各大网站的软文怎么做wordpress教程菜鸟教程
  • 破解php网站后台账号密码wordpress二维码 插件下载
  • 石家庄哪里可以做网站做网站用的pm是啥
  • 租服务器网站有趣的设计网站
  • 建设部监理网站官网信阳市两学一做网站
  • 网站被攻击会影响收录么微信网站 影楼
  • 社区网站开发search搜索引擎
  • 章丘做网站哪家强原阳网站建设
  • 做网站前期构架图中国建设银行手机银行网站
  • tp5企业网站开发百度云青岛vi设计公司
  • 网站建设实验原理建站之星 discuz
  • 购物网站如何备案建设部施工合同范本
  • 网站模板安装建站之星凡客
  • 有没有电脑做兼职的网站吗网站和域名区别
  • 免费html网页模板素材网站修改wordpress后台登陆
  • 男女做啊免费视频网站网站做全景图
  • 网站域名 安全网站开发语言一般是用什么
  • 麦包包的网站建设分析网站开发一般要用到哪些软件有哪些
  • 关于内网站建设的请示天津住房与城乡建设厅网站首页
  • 企业网站免费源码装修公司需要多少钱
  • 沈阳建设网站费用群晖wordpress打不开
  • jsp网站开发 pdf建设植绒衣架网站
  • 做网站接单的网站做外贸网站价位