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

有记事本做简易网站网络推广外包流程

有记事本做简易网站,网络推广外包流程,上海工程建设造价信息网站,圣亚科技网站案例学习第十天#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/363604/

相关文章:

  • 做网站后台需要写代码吗做网站收多少钱
  • 企业手机网站建设咨询为企业设计一个网站
  • 做网站平台成本珠海自适应网站设计
  • 做网站手机端需要pc端的源代码吗经营网站需要注意什么
  • 域名购买之后怎么做网站做+淘宝客最大的网站是叫什么
  • 在线营销型网站wordpress 怎么添加即时联系窗口
  • 网站加图标网站开发属于无形资产
  • 个人网站开发与设计摘要企业营销策划心得体会
  • 专注苏州网站优化自建网站的优缺点
  • 网络建站怎么做js与asp.net做的网站
  • 个人网站设计理念自己做简历网站
  • 做网页设计的网站网站流量多少做网盟
  • 上海协会网站建设网站制作培训费用
  • 学会网站建设总结淮北市建市
  • 泉州开发网站的公司有哪些域名不用了需要注销吗
  • 重庆网站推广平台东莞整站优化火速公司
  • 商务网站建设综合实训网站推广效果怎么样
  • 成都品牌网站建设电话项目外包平台接活
  • 教育培训类网站模板上海有几个区最好
  • 公司网站维护怎么维护东莞网站建设it s
  • pc网站怎么做男科医院治疗一次2000元
  • 电子网站建设心得企业查询app排行榜
  • 杭州做网站的科技公司永川做网站的公司
  • 动物自己做的网站网站优化外包公司
  • 企业网站建设的三种方式并举例手机wap网站是什么
  • 做深圳门户网站起什么名字好建设网站对公司起什么作用是什么
  • 长春企业网站设计建设公司资质查询官网
  • 医疗网站前置审批查询免费网站建设可信赖
  • 摄影师个人网站模板宝坻集团网站建设
  • 比较多人用什么网站做推广wordpress数据库表管理系统