随笔分类 -  Java基础编程

简单的程序设计
摘要:假设圆的半径为1,圆的面积为PI,外接正方形的面积为4. 随机产生一个点落在圆内的概率为PI/4 import java.util.*; class Main { public static void main(String[] args){ final int NUMBER_OF_TRIALS = 阅读全文
posted @ 2022-05-20 11:19 Scenery_Shelley 阅读(40) 评论(0) 推荐(0)
摘要:假设某个大学今年的学费是10000美金,且以每年7%的速度增加。多少年后学费会翻倍? import java.util.*; class Main { public static void main(String[] args){ double tuition = 10000; int year = 阅读全文
posted @ 2022-05-20 11:05 Scenery_Shelley 阅读(91) 评论(0) 推荐(0)
摘要:第一种方法 import java.util.*; class Main { public static void main(String[] args){ //Create a scanner Scanner input = new Scanner(System.in); //Prompt the 阅读全文
posted @ 2022-05-19 20:29 Scenery_Shelley 阅读(24) 评论(0) 推荐(0)
摘要:从大到小添加数字没有从小到大添加数字精确 在大数之前先增加小数是减小误差的一种方法 import java.util.*; class Main { public static void main(String[] args){ //Initialize sum float sum = 0; //A 阅读全文
posted @ 2022-05-19 20:16 Scenery_Shelley 阅读(37) 评论(0) 推荐(0)
摘要:import java.util.*; class Main { public static void main(String[] args){ //Display the table heading System.out.println(" Multiplication Table"); //Di 阅读全文
posted @ 2022-05-19 19:58 Scenery_Shelley 阅读(26) 评论(0) 推荐(0)
摘要:使用while循环实现 import java.util.*; class Main { public static void main(String[] args){ //Create a Scanner Scanner input = new Scanner(System.in); //Read 阅读全文
posted @ 2022-05-17 16:49 Scenery_Shelley 阅读(41) 评论(0) 推荐(0)
摘要:import java.util.*; import javax.swing.*; class Main { public static void main(String[] args){ int number = (int)(Math.random()* 101); Scanner input = 阅读全文
posted @ 2022-05-17 15:46 Scenery_Shelley 阅读(33) 评论(0) 推荐(0)
摘要:圆心之间的距离和 |r1-r2|及(r1+r2)之间比较 import java.util.*; import javax.swing.*; class Main { public static void main(String[] args){ Scanner input = new Scanne 阅读全文
posted @ 2022-05-17 15:30 Scenery_Shelley 阅读(257) 评论(0) 推荐(0)
摘要:PL1,PR1 表示为矩形1 的左上角 和 右下角 的 点 PL2,PR2 表示为矩形2 的左上角 和 右下角 的 点 PR1.x ⇐ PL2.x 表示矩形1 在矩形2 的左边,不重叠 PL1.x >= PR2.x 表示矩形1 在矩形2 的右边,不重叠 PL1.y ⇐ PR2.y 表示矩形1 在矩形 阅读全文
posted @ 2022-05-17 10:51 Scenery_Shelley 阅读(943) 评论(0) 推荐(0)
摘要:import java.util.*; import javax.swing.*; class Main { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.prin 阅读全文
posted @ 2022-05-15 22:54 Scenery_Shelley 阅读(363) 评论(0) 推荐(0)
摘要:import java.util.*; import javax.swing.*; class Main { public static void main(String[] args){ int cardNumber = (int)(Math.random() * 100) % 13; int c 阅读全文
posted @ 2022-05-15 22:43 Scenery_Shelley 阅读(94) 评论(0) 推荐(0)
摘要:点是否在圆内 import java.util.*; import javax.swing.*; class Main { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.o 阅读全文
posted @ 2022-05-15 14:48 Scenery_Shelley 阅读(46) 评论(0) 推荐(0)
摘要:泽勒一致性 import java.util.*; import javax.swing.*; class Main { public static void main (String[] args){ Scanner input = new Scanner(System.in); System.o 阅读全文
posted @ 2022-05-13 12:57 Scenery_Shelley 阅读(43) 评论(0) 推荐(0)
摘要:import java.util.*; import javax.swing.*; class Main { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.prin 阅读全文
posted @ 2022-05-13 12:21 Scenery_Shelley 阅读(45) 评论(0) 推荐(0)
摘要:猜一次 import java.util.*; class Main { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.print("scissor(0), roc 阅读全文
posted @ 2022-05-13 11:37 Scenery_Shelley 阅读(40) 评论(0) 推荐(0)
摘要:使用System.currentTimeMillis()方法 public class HelloWorld { public static void main(String []args) { long totalMilliseconds = System.currentTimeMillis(); 阅读全文
posted @ 2022-05-13 10:44 Scenery_Shelley 阅读(115) 评论(0) 推荐(0)
摘要:生成输入框 String numberString1 = JOptionPane.showInputDialog("Enter the first number: "); 生成消息框 JOptionPane.showMessageDialog(null, number1 + " <= " + num 阅读全文
posted @ 2022-05-11 15:47 Scenery_Shelley 阅读(32) 评论(0) 推荐(0)
摘要:ax^2 + bx + c = 0 import javax.swing.JOptionPane; import java.util.*; class Main { public static void main(String[] args){ Scanner input = new Scanner 阅读全文
posted @ 2022-05-11 14:54 Scenery_Shelley 阅读(38) 评论(0) 推荐(0)
摘要:[0,20) [10,20) [10,50] import javax.swing.JOptionPane; import java.util.*; class Main { public static void main(String[] args){ int number = (int)(Mat 阅读全文
posted @ 2022-05-11 13:04 Scenery_Shelley 阅读(39) 评论(0) 推荐(0)
摘要:运算符优先级表(从高到低) ++在前,先变后用,++在后,先用后变 var++ var--() +、-(一元加减)、++var 、--var 、(type) ! 、/、% 、-(二元加减) <、<= 、> 、>= == 、!= ^ && | | = 、+= 、-= 、*= 、/= 、%= 相邻运算符 阅读全文
posted @ 2022-05-11 12:18 Scenery_Shelley 阅读(124) 评论(0) 推荐(0)