大数据 | 您所在的位置:网站首页 › 123456猜一个数字 › 大数据 |
1.缸子里能装50升水。现有15升。每次能挑5升。要挑几次才能挑满? 分析: 1.定一个变量 a 来存储每次挑的水 2. 定义一个变量 b 来显示挑水的次数 3.判断条件为挑满水为止 public class Excericse05 { public static void main(String[] args) { int a =5 ; int b =1; while((a*b)+15 public static void main(String []agrs) { int a =1; int i =0; while (i System.out.print(i+","); a++; } i++; } } }3.使用do-while实现:输出摄氏温度与华氏温度的对照表,要求它从摄氏温度0度到250度,每隔20度为一项,对照表中的条目不超过10条。 转换关系:华氏温度 = 摄氏温度 * 9 / 5.0 + 32 分析: 1.定义变量a 显示摄氏度温度,并且以20度为一项 2.定义一个变量b 来存储华式温度 3.定义i 来限制每页的条数 public class Excericise03 { public static void main(String[] args) { int a = 0; int i =0; double b =32; do { System.out.println(a+"摄氏度"+"--"+b+"华式温度"); a =a +20; b =a*9/5.0+32.0; }while(a Scanner sc = new Scanner (System.in); System.out.println("请输入一个在0-9的整数"); int a =sc.nextInt(); int b = 1; int c = 1; while( c public static void main(String[] args) { Scanner sc = new Scanner (System.in); System.out.print("请输入您想要求的次方值"); int a = sc.nextInt(); double power= 1; int c=1; if(a >=0) { while (c while(a public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("开始猜数字游戏!!请输入一个数字(数字介于0-10)"); int a = 0; int b = 3; do { a = sc.nextInt(); if (a > b ) { System.out.println("您输入的值过大,请继续输入新的值"); }else if (a |
CopyRight 2018-2019 实验室设备网 版权所有 |