正在加载图片...
Loop Control without Boolean variable sum =0: do num inputBox. getInteger()i if (num == 0) //sentinel messageBox. show("Sum = sum else if (num 9 2 //invalid data messageBox. show( Error: even number was entered") else sum + num if(sum > 1000) //pass the threshold essageBox. show(" Sum became larger than 1000) y while(!(num 2 ==0 num ==0I sum > 1000)) C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 7-16© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 7 - 16 Loop Control without Boolean Variable sum = 0; do { num = inputBox.getInteger(); if (num == 0) //sentinel messageBox.show("Sum = " + sum); else if (num % 2 == 0) //invalid data messageBox.show("Error: even number was entered"); else { sum += num; if (sum > 1000) //pass the threshold messageBox.show("Sum became larger than 1000"); } } while ( !(num % 2 == 0 || num == 0 || sum > 1000) );
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有