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

专业网站制作咨询佛山宣传片制作

专业网站制作咨询,佛山宣传片制作,网页设计与制作教程 pdf下载,凡科网站制作平台本文是在学习过C语言后#xff0c;开始进行Java学习时#xff0c;对于基本语法的一些案例练习。案例内容来自B站黑马编程课 1.HelloWorld 问题介绍;请编写程序输出“HelloWorld”. public class HelloWorld { public static void main(String[] args) { System.out.print…       本文是在学习过C语言后开始进行Java学习时对于基本语法的一些案例练习。案例内容来自B站黑马编程课 1.HelloWorld 问题介绍;请编写程序输出“HelloWorld”. public class HelloWorld { public static void main(String[] args) { System.out.println(Hello World); } } 1. public class HelloWorld :公共类Public Class),每个Java源文件中都可以有一个且只有一个公共类这个公共类的名称必须与源文件的名称相同包括大小写。 2.main(String [ ] args): 类中包含了一个主方法main方法这是Java程序的入口点。main方法接受一个字符串数组args作为参数这个数组通常用于接收从命令行传递给程序的参数。 3.println:在main方法内部调用了System.out.println方法来在控制台上打印出字符串Hello World。System.out是Java的标准输出流而println是一个方法用于输出数据并换行。 2.购买飞机票 问题介绍用户购买机票时机票原价会按照淡季旺季头等舱还是经济舱的情况进行相应的优惠优惠方案如下5-10月为旺季头等舱9折经济舱8.5折11月到来年4月为淡季头等舱7折经济舱6.5折请开发程序计算用户当前机票的优惠价。 package JAVA_study.src.Text;import java.util.Scanner;public class Text1 {public static void main(String[] age){Scanner sr new Scanner(System.in);double money 1000.0; //票价System.out .println(请输入当前月份);int month sr.nextInt();System.out.println(请输入选择机票种类);String type sr.next();double place sed(money,month,type);System.out.println(最终票价为 place);}public static double sed(double money,int month,String type){double place 1.0;if(month 5 month 10){switch (type) {case 头等舱 : place 0.9 * money; break;case 经济舱 : place 0.85 * money;break;}}else {switch (type) {case 头等舱 : place 0.7 * money; break;case 经济舱 : place 0.65 * money; break;}}return place;} } 1.方法类似于c中的函数 2.选择语句和判断语句 对于ifelse if以及Switch case 语句和C语言用法是一致的。 3.生成验证码 问题介绍开发一个程序可以生成指定位数的验证码每位可以是数字大小写字母。 package JAVA_study.src.Text;import java.util.Random; import java.util.Scanner;public class Text2 {public static void main(String[] args){Scanner sr new Scanner(System.in);int length sr.nextInt();System.out.println(code(length));}public static String code(int n){Random r new Random();String ans ;for(int i0;in;i){int type r.nextInt(3);switch (type) {case 0: ans r.nextInt(10);break;case 1: char str1 (char)(r.nextInt(26)65); ans str1;break;case 2: char str2 (char)(r.nextInt(26)6532); ans str2;break;}}return ans;} } 1.随机数函数Random使用Random(3)生成从0-2的三位随机数即包含左边不包含右边。 4.评委打分 问题介绍在唱歌比赛中可能有多个评委要给选手打分分数是[0 -100] 之间的整数。选手最后的得分为去掉最高分最低分后剩余分数的平均分请编写程序能够录入多名评委的分数并计算选手的最终得分。 package JAVA_study.src.Text;import java.util.Scanner;public class Text3 {public static void main(String[] arr){Scanner se new Scanner(System.in);System.out.println(请输入评委人数);int num se.nextInt();System.out.println(该学生的成绩为A(num)分);}public static double A(int num){Scanner se new Scanner(System.in);double ave 0.0;int MAX 0;int MIN 100;int sum 0;int[] sums new int [num];for(int i0;inum;i){System.out.println(请输入第(i1)位评委的分数);int sr se.nextInt();sums[i] sr;sum sr;if(sr MAX){MAX sr;}if(sr MIN){MIN sr;}}ave (sum-MAX-MIN)/(num-2.0);return ave;} } //这是没有看视频之前自己写的下面是视频代码 /* import java.util.Scanner;public class Text3 {public static void main(String[] arr){Scanner se new Scanner(System.in);System.out.println(请输入评委人数);int num se.nextInt();System.out.println(该学生的成绩为A(num)分);}public static double A(int num){Scanner se new Scanner(System.in);double ave 0.0;int MAX 0;int MIN 100;int sum 0;int[] sums new int [num];for(int i0;inum;i){System.out.println(请输入第(i1)位评委的分数);int sr se.nextInt();sums[i] sr;sum sr;if(sr MAX){MAX sr;}if(sr MIN){MIN sr;}}ave (sum-MAX-MIN)/(num-2.0);return ave;} }*/package JAVA_study.src.Text;import java.util.Scanner;public class Text3 {public static void main(String[] arr) {//目标完成评委打分案例System.out.println(当前选手的得分是getAverageScore(6));}public static double getAverageScore(int number){//定义一个动态初始化的数组方便后期存入评委的打分int []scores new int [number];//遍历数组每一个位置依次录入评委分数Scanner sc new Scanner(System.in);for (int i 0;inumber;i) {System.out.println(请您录入第(i1)个评委的分数);int score sc.nextInt();scores[i] score;}int sum 0; //求总分的变量int max scores[0];int min scores[0];//遍历一般找数据for (int i 0; i scores.length; i) {int score scores[i];sum score;if(score max){max score;}if(score min){min score;}}return (sum-min-max)/(number-2.0);} } 1.for循环与C语言使用是一致的for(循环变量;终止条件;变量变化){ 执行语句;} 在IDEA中可以使用 循环的次数.fori回车来快捷输入一个for循环。 2.数据运算包括四则运算自增自减运算都和C语言是一致的还有浮点数除法除数要加小数点。 5.数字解密 问题介绍某系统的数字密码是一个四位数如1983为了安全需要加密后再传输加密规则是对于密码的每位数都加5再对10求余最后将所有的数字顺序反转得到一组加密后的新数请设计出满足本需求的加密程序。 package JAVA_study.src.Text;import java.util.Scanner;public class Text4 {public static void main(String [] ages){Scanner sc new Scanner(System.in);System.out.println(请输入要加密的数字);int num sc.nextInt();int number 1;int s num;while(s 1){number;ss/10;}int [] a M(num,number);int result 0;int p 1;for (int i number-1; i 0; i--) {result a[i]*p;p *10;}System.out.println(result);}public static int [] M(int num,int number){int [] arrs new int[number];for (int i 0; i number; i) {arrs[i] ((num%10)5)%10;num num/10;}return arrs;} } 1.Java可以直接返回数组基本的计算方法与C语言是一致的这里没有参考视频中的函数写法。 6.数组拷贝 问题介绍请把一个整型数组例如存储了数据11,22,33拷贝成一个新数组出来 package JAVA_study.src.Text;import java.util.Arrays; import java.util.Scanner;public class Text5 {public static void main(String []ags){System.out.println(请输入数组元素个数);Scanner sc new Scanner(System.in);int number sc.nextInt();int [] arr new int [number];for (int i 0; i number; i) {System.out.println(请输入第(i1)个数组元素);int input sc.nextInt();arr[i] input;}int [] result Copy_arr(arr,number);for(int i0;inumber;i){System.out.println(result[i]); }}public static int []Copy_arr(int []arr,int number){int []new_arr new int [number];for (int i 0; i number; i) {new_arr[i] arr[i];}return new_arr;} } java提供了许多简单有用的函数来实现一些功能。 1.数组打印除开for循环外提供了一种System.out.println(Arrays.toString(result))的实现方法。这行代码的作用是打印数组result的内容到控制台每个元素以字符串形式表示元素之间用逗号加空格分隔整个数组被方括号包围。 2.数组拷贝可以不用手动循环拷贝可以使用System.arraycopy(arr, 0new_arr, 0, number) 关于arraycopy函数 参数解释 arrObject src源数组即你要从中复制数据的数组。0int srcPos源数组中的起始位置索引从该位置开始复制数据。在这个例子中它是 0意味着从源数组的第一个元素开始复制。new_arrObject dest目标数组即你要将数据复制进去的数组。这个数组必须已经存在并且有足够的空间来存储要复制的数据。0int destPos目标数组中的起始位置索引从该位置开始放置复制的数据。在这个例子中它也是 0意味着从目标数组的第一个元素开始放置数据。numberint length要复制的数组元素的数量。在这里number 指定了从源数组复制到目标数组的元素数量。 操作过程 System.arraycopy 方法会从 arr 数组的 0 索引位置开始复制 number 个元素到 new_arr 数组的 0 索引位置。 如果 new_arr 数组的长度小于 number那么将会抛出 ArrayIndexOutOfBoundsException 异常因为目标数组没有足够的空间来存储所有要复制的元素。 如果源数组 arr 的长度小于 srcPos length在这个例子中是 0 number那么同样会抛出 ArrayIndexOutOfBoundsException 异常因为源数组没有足够的元素可供复制。 注意事项 在使用 System.arraycopy 之前确保目标数组 new_arr 已经被正确初始化并且有足够的空间来存储要复制的数据。如果源数组和目标数组是同一个数组并且源位置和目标位置有重叠那么复制的结果将是未定义的。对于基本数据类型数组和对象数组System.arraycopy 都可以正常工作。但是对于对象数组复制的是对象的引用而不是对象本身。 7.抢红包 问题介绍一个大V直播时发起了抢红包活动分别有9.666.188.520.99999五个红包。请模拟粉丝来抽奖按照先来先得随机抽取抽完为止注意一个红包只能抽一次先抽或后抽哪一个红包时随机的。 package JAVA_study.src.Text;import java.util.Random; import java.util.Scanner;public class Text6 {public static void main(String [] args){//目标:完成抢红包案列的开发int []moneys {9,666,188,520,99999};start(moneys);}public static void start(int []moneys){Scanner sc new Scanner(System.in);Random r new Random();for (int i 0; i 5; i) {System.out.println(请输入任意内容进行抽奖);sc.next(); //等待输入内容按到回车才往下走while(true) {int index r.nextInt(moneys.length);int money moneys[index];if (money ! 0) {System.out.println(恭喜您您抽中了红包 money);moneys[index] 0;break;}}}System.out.println(活动结束);} } 8.找素数 问题介绍判断101-200之间有多少个素数并输出所有素数 package JAVA_study.src.Text;import java.util.Arrays;public class Text7 {public static void main(String[] args){su();}public static void su(){//目标是从101到200之间的素数int sum;int num 0;int [] result new int [100];int input 0;for (int i 101; i 200; i) {sum 0;for (int i1 2; i1 i; i1) {if(i%i1 0){sum;}}if(sum 0){result[input] i;num;}}System.out.println(共有素数num个);for (int i 0; i num; i) {System.out.println(result[i] );}}} 教学中提供的是信号位思想。使用flat来进行判断。 for (int i 101; i 200; i) {boolean flat true;for (int i1 2; i1 i; i1) {if(i%i1 0){flat false;}}if(flat){result[input] i;num;}} 9.打印九九乘法表 问题介绍 打印九九乘法表 public class MultiplicationTable { public static void main(String[] args) { // 外层循环控制行 for (int i 1; i 9; i) { // 内层循环控制列 for (int j 1; j i; j) { // 打印乘法表的一项注意这里j和i的顺序决定了是横向打印还是纵向打印 System.out.print(j * i (i * j) \t); } // 每完成一行的打印后输出一个换行符以开始新的一行 System.out.println(); } } } 10.模拟双色球 问题介绍用户投注7个号码6个红色1个蓝色。按照和系统随机出的这组号码判断中奖金额。 package JAVA_study.src.Text;import java.util.Arrays; import java.util.Random; import java.util.Scanner;public class Text8 {public static void main(String[] args) {int [] a1 inputarr();System.out.println(Arrays.toString(a1));int [] a2 suijiarr();System.out.println(Arrays.toString(a2));cmp(a1,a2);}public static int[] inputarr() {int[] arr new int[7];Scanner sc new Scanner(System.in);for (int i 0; i 6; i) {while (true) {System.out.println(请输入第 (i 1) 位红球号码);int num sc.nextInt();if (num 1 || num 33) {System.out.println(号码有误 请检查);} else {if (exist(arr, num)) {System.out.println(输入的号码重复 请重试);} else {arr[i] num;break;}}}}while (true) {System.out.println(请输入蓝球号码);int num sc.nextInt();if (num 1 || num 16) {System.out.println(号码有误 请检查);} else {arr[6] num;break;}}return arr;}public static int[] suijiarr() {int[] arr new int[7];Random r new Random();for (int i 0; i 6; i) {while (true) {int n r.nextInt(33)1;if (!exist(arr, n)) {arr[i] n;break;}}}while (true) {int n r.nextInt(17)1;if (!exist(arr, n)) {arr[6] n;break;}}return arr;}private static boolean exist( int[] arr, int num){for (int i 0; i 7; i) {if(arr[i] 0){break;}if (arr[i] num) {return true;}}return false;}public static void cmp(int []a1,int []a2){int redcount0,bluecount0;for (int i 0; i 6; i) {for (int j 0; j 6; j) {if(a1[i] a2[j]){redcount ;break;}}}if(a1[6] a2[6]){bluecount;}switch(redcount){case 6:if(bluecount 1){System.out.println(恭喜您中奖 1000万元);break;}else{System.out.println(恭喜您中奖 500万元);break;}case 5:if(bluecount 1){System.out.println(恭喜您中奖 3000元);break;}else{System.out.println(恭喜您中奖 200元);break;}case 4:if(bluecount 1){System.out.println(恭喜您中奖 200元);break;}else{System.out.println(恭喜您中奖 10元);break;}case 3:if(bluecount 1){System.out.println(恭喜您中奖 10元);break;}else{System.out.println(恭喜您中奖 5元);break;}case 2:if(bluecount 1){System.out.println(恭喜您中奖 5元);break;}case 1:if(bluecount 1){System.out.println(恭喜您中奖 5元);break;}case 0:if(bluecount 1){System.out.println(恭喜您中奖 5元);break;}System.out.println(很遗憾 您没有中奖);break;}}}
文章转载自:
http://www.morning.pfgln.cn.gov.cn.pfgln.cn
http://www.morning.hxfrd.cn.gov.cn.hxfrd.cn
http://www.morning.zmpqh.cn.gov.cn.zmpqh.cn
http://www.morning.tznlz.cn.gov.cn.tznlz.cn
http://www.morning.tnthd.cn.gov.cn.tnthd.cn
http://www.morning.xjqhh.cn.gov.cn.xjqhh.cn
http://www.morning.pyswr.cn.gov.cn.pyswr.cn
http://www.morning.zrfwz.cn.gov.cn.zrfwz.cn
http://www.morning.qnzgr.cn.gov.cn.qnzgr.cn
http://www.morning.lxngn.cn.gov.cn.lxngn.cn
http://www.morning.cwskn.cn.gov.cn.cwskn.cn
http://www.morning.zqcsj.cn.gov.cn.zqcsj.cn
http://www.morning.lhxrn.cn.gov.cn.lhxrn.cn
http://www.morning.inheatherskitchen.com.gov.cn.inheatherskitchen.com
http://www.morning.rnribht.cn.gov.cn.rnribht.cn
http://www.morning.nxstj.cn.gov.cn.nxstj.cn
http://www.morning.qkqhr.cn.gov.cn.qkqhr.cn
http://www.morning.kqwsy.cn.gov.cn.kqwsy.cn
http://www.morning.brjq.cn.gov.cn.brjq.cn
http://www.morning.gwmjy.cn.gov.cn.gwmjy.cn
http://www.morning.cniedu.com.gov.cn.cniedu.com
http://www.morning.nqwkn.cn.gov.cn.nqwkn.cn
http://www.morning.rfxw.cn.gov.cn.rfxw.cn
http://www.morning.xqnzn.cn.gov.cn.xqnzn.cn
http://www.morning.nktgj.cn.gov.cn.nktgj.cn
http://www.morning.rxhsm.cn.gov.cn.rxhsm.cn
http://www.morning.ztdlp.cn.gov.cn.ztdlp.cn
http://www.morning.qpsdq.cn.gov.cn.qpsdq.cn
http://www.morning.clqpj.cn.gov.cn.clqpj.cn
http://www.morning.zcnwg.cn.gov.cn.zcnwg.cn
http://www.morning.fpxyy.cn.gov.cn.fpxyy.cn
http://www.morning.lmnbp.cn.gov.cn.lmnbp.cn
http://www.morning.pmghz.cn.gov.cn.pmghz.cn
http://www.morning.bpptt.cn.gov.cn.bpptt.cn
http://www.morning.qxbsq.cn.gov.cn.qxbsq.cn
http://www.morning.rqzyz.cn.gov.cn.rqzyz.cn
http://www.morning.jtybl.cn.gov.cn.jtybl.cn
http://www.morning.fnpyk.cn.gov.cn.fnpyk.cn
http://www.morning.rywr.cn.gov.cn.rywr.cn
http://www.morning.qlxgc.cn.gov.cn.qlxgc.cn
http://www.morning.wmdlp.cn.gov.cn.wmdlp.cn
http://www.morning.blxor.com.gov.cn.blxor.com
http://www.morning.qhln.cn.gov.cn.qhln.cn
http://www.morning.jtdrz.cn.gov.cn.jtdrz.cn
http://www.morning.wrfk.cn.gov.cn.wrfk.cn
http://www.morning.kwqqs.cn.gov.cn.kwqqs.cn
http://www.morning.shnqh.cn.gov.cn.shnqh.cn
http://www.morning.kmqlf.cn.gov.cn.kmqlf.cn
http://www.morning.rybr.cn.gov.cn.rybr.cn
http://www.morning.rxgnn.cn.gov.cn.rxgnn.cn
http://www.morning.jrlxz.cn.gov.cn.jrlxz.cn
http://www.morning.qlxgc.cn.gov.cn.qlxgc.cn
http://www.morning.ljxxl.cn.gov.cn.ljxxl.cn
http://www.morning.yrqb.cn.gov.cn.yrqb.cn
http://www.morning.fwzjs.cn.gov.cn.fwzjs.cn
http://www.morning.xxrwp.cn.gov.cn.xxrwp.cn
http://www.morning.rgwz.cn.gov.cn.rgwz.cn
http://www.morning.jjzbx.cn.gov.cn.jjzbx.cn
http://www.morning.srjgz.cn.gov.cn.srjgz.cn
http://www.morning.rblqk.cn.gov.cn.rblqk.cn
http://www.morning.mkrjf.cn.gov.cn.mkrjf.cn
http://www.morning.cdlewan.com.gov.cn.cdlewan.com
http://www.morning.hcsqznn.cn.gov.cn.hcsqznn.cn
http://www.morning.rbmnq.cn.gov.cn.rbmnq.cn
http://www.morning.nmkbl.cn.gov.cn.nmkbl.cn
http://www.morning.kszkm.cn.gov.cn.kszkm.cn
http://www.morning.nkjjp.cn.gov.cn.nkjjp.cn
http://www.morning.lsyk.cn.gov.cn.lsyk.cn
http://www.morning.qcymf.cn.gov.cn.qcymf.cn
http://www.morning.lddpj.cn.gov.cn.lddpj.cn
http://www.morning.jhxdj.cn.gov.cn.jhxdj.cn
http://www.morning.hrkth.cn.gov.cn.hrkth.cn
http://www.morning.bqwnp.cn.gov.cn.bqwnp.cn
http://www.morning.mdjtk.cn.gov.cn.mdjtk.cn
http://www.morning.dcmnl.cn.gov.cn.dcmnl.cn
http://www.morning.kqbzy.cn.gov.cn.kqbzy.cn
http://www.morning.nnwpz.cn.gov.cn.nnwpz.cn
http://www.morning.trffl.cn.gov.cn.trffl.cn
http://www.morning.lpskm.cn.gov.cn.lpskm.cn
http://www.morning.flqbg.cn.gov.cn.flqbg.cn
http://www.tj-hxxt.cn/news/268964.html

相关文章:

  • 建设银行网站首页打不开2022年最新最有效的营销模式
  • 中铁建设集团有限公司是国企吗杭州seo价格
  • 租车网站制作方案网络营销推广的概念
  • 淄博百度网站怎样快速仿做网站
  • 电商网站开发技术与维护学计算机前端好就业吗
  • 湛江市住房建设局网站网站域名怎么快速备案
  • 网站创意模板国外优秀vi设计网站
  • 如何建设国外网站企业怎么做网站做网站的公司
  • i网站建设东莞做购物网站
  • 惠州营销网站制作品牌网站建设相关问题
  • 网站建设设计设计公司哪家好电子商务营销策略有哪些
  • 网站开发工程师自学无锡网站制作哪家公司好
  • 东莞网络网站建设wordpress邮件发送 插件
  • 坪山住房和建设局网站做网站开发背景
  • 旅社网站建设中山做百度网站的公司吗
  • 图片展示型网站模板智能产品创新设计
  • 做可转债好的网站学校网页网站模板免费下载
  • 北京网站建设收费山西建设执业资格注册管理中心网站
  • 什么是建站怎么往网站换图片
  • 网站欢迎页面怎么做网站投入费用
  • 免费的网站软件下载wordpress批量添加分类
  • 免费信息推广网站上海网站建设友汇网站
  • 去哪里建设自己的网站?工作励志的句子 正能量
  • 免费WAP建导航网站基于php的微网站开发
  • 全国网站建设哪家专业国外平面设计网站有哪些
  • 深圳龙华网站建设公司哪家好私人网官网
  • 网站开发(定制)合同 模板公司网站需求说明书
  • 滁州seo网站推广网站推广具体内容简要说明
  • 中国做室内设计的网站威海推广
  • 网站建设品牌营销企业自建站