当前位置:网站首页>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 ?
边栏推荐
- Statistics 8th Edition Jia Junping Chapter 7 Summary of knowledge points and answers to exercises after class
- [oiclass] maximum formula
- High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters
- ByteDance ten years of experience, old bird, took more than half a year to sort out the software test interview questions
- The common methods of servlet context, session and request objects and the scope of storing data in servlet.
- [pointer] the array is stored in reverse order and output
- 函数:求方程的根
- 指针--剔除字符串中的所有数字
- 数据库多表链接的查询方式
- Want to learn how to get started and learn software testing? I'll give you a good chat today
猜你喜欢
Keil5-MDK的格式化代码工具及添加快捷方式
MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
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)
The common methods of servlet context, session and request objects and the scope of storing data in servlet.
Cc36 different subsequences
Fundamentals of digital circuits (III) encoder and decoder
CSAPP家庭作業答案7 8 9章
Wang Shuang's detailed notes on assembly language learning I: basic knowledge
数字电路基础(三)编码器和译码器
随机推荐
MySQL development - advanced query - take a good look at how it suits you
Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator
1.支付系统
What is the transaction of MySQL? What is dirty reading and what is unreal reading? Not repeatable?
Statistics 8th Edition Jia Junping Chapter XIII Summary of knowledge points of time series analysis and prediction and answers to exercises after class
Interview Essentials: what is the mysterious framework asking?
函数:求1-1/2+1/3-1/4+1/5-1/6+1/7-…+1/n
指针:最大值、最小值和平均值
Global and Chinese market of maleic acid modified rosin esters 2022-2028: Research Report on technology, participants, trends, market size and share
后台登录系统,JDBC连接数据库,做小案例练习
Functions: Finding Roots of equations
Fundamentals of digital circuit (V) arithmetic operation circuit
The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?
STC-B学习板蜂鸣器播放音乐
Practical cases, hand-in-hand teaching you to build e-commerce user portraits | with code
Statistics 8th Edition Jia Junping Chapter 12 summary of knowledge points of multiple linear regression and answers to exercises after class
数字电路基础(二)逻辑代数
Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
【指针】删除字符串s中的所有空格
Matplotlib绘图快速入门