当前位置:网站首页>Daily code 300 lines learning notes day 9
Daily code 300 lines learning notes day 9
2022-07-06 15:03:00 【Leeyz_ one】
1. Yes while Loop for basic implementation
This section is relatively simple , So run the code directly
Code segment :
package demo3;
public class While {
/**
*********************
* The entrance of the program.
*
* @param args Not used now.
*********************
*/
public static void main(String args[]) {
whileStatementTest();
}// Of main
public static void whileStatementTest() {
int tempMax = 100;
int tempValue = 0;
int tempSum = 0;
// Approach 1.
while (tempSum <= tempMax) {
tempValue++;
tempSum += tempValue;
System.out.println("tempValue = " + tempValue + ", tempSum = " + tempSum);
} // Of while
tempSum -= tempValue;
System.out.println("The sum not exceeding " + tempMax + " is: " + tempSum);
// Approach 2.
System.out.println("\r\nAlternative approach.");
tempValue = 0;
tempSum = 0;
while (true) {
tempValue++;
tempSum += tempValue;
System.out.println("tempValue = " + tempValue + ", tempSum = " + tempSum);
if (tempMax < tempSum) {
break;
} // Of if
} // Of while
tempSum -= tempValue;
System.out.println("The sum not exceeding " + tempMax + " is: " + tempSum);
}// Of whileStatementTest
}//Of While
Running results :

2. summary
Like the comments on the eighth line and the previously learned code , Why do you often give one in that position args not used now Notes of ?
边栏推荐
- Login the system in the background, connect the database with JDBC, and do small case exercises
- 函数:求方程的根
- [pointer] find the value of the largest element in the two-dimensional array
- 刷视频的功夫,不如看看这些面试题你掌握了没有,慢慢积累月入过万不是梦。
- 使用 flask_whooshalchemyplus jieba实现flask的全局搜索
- Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary
- 函数:求1-1/2+1/3-1/4+1/5-1/6+1/7-…+1/n
- Install and run tensorflow object detection API video object recognition system of Google open source
- [issue 18] share a Netease go experience
- [oiclass] share prizes
猜你喜欢

Keil5 MDK's formatting code tool and adding shortcuts

数字电路基础(三)编码器和译码器

STC-B学习板蜂鸣器播放音乐2.0

“Hello IC World”

Software testing interview summary - common interview questions

Statistics 8th Edition Jia Junping Chapter 2 after class exercises and answer summary

Build your own application based on Google's open source tensorflow object detection API video object recognition system (II)

How to transform functional testing into automated testing?
![Cadence physical library lef file syntax learning [continuous update]](/img/0b/75a4ac2649508857468d9b37703a27.jpg)
Cadence physical library lef file syntax learning [continuous update]

CSAPP homework answers chapter 789
随机推荐
Global and Chinese market of pinhole glossmeter 2022-2028: Research Report on technology, participants, trends, market size and share
CSAPP homework answers chapter 789
【指针】求解最后留下的人
ucore lab2 物理内存管理 实验报告
Get started with Matplotlib drawing
Statistics 8th Edition Jia Junping Chapter 12 summary of knowledge points of multiple linear regression and answers to exercises after class
The four connection methods of JDBC are directly coded
四元数---基本概念(转载)
[pointer] find the length of the string
DVWA exercise 05 file upload file upload
Face and eye recognition based on OpenCV's own model
Cc36 different subsequences
The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?
Function: find the root of the equation by Newton iterative method
servlet中 servlet context与 session与 request三个对象的常用方法和存放数据的作用域。
Report on the double computer experiment of scoring system based on 485 bus
Matplotlib绘图快速入门
Build your own application based on Google's open source tensorflow object detection API video object recognition system (II)
Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
线程的实现方式总结