正在加载图片...
Person array Processing-2 r Find the average age of 18-year-old males float sum =0, averageR t count 0 person f( person[i]. getAge( 18& person[i]. getGender()=M)t sum + person [i]. getAge () averageAge= sum/ count C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 9-16© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 9 - 16 Person Array Processing - 2 Find the average age of 18-year-old males. float sum = 0, averageAge; int count = 0; for (int i = 0; i < person.length; i++) { if ( person[i].getAge( ) = 18 && person[i].getGender{ } = ‘M’ ) { sum += person[i].getAge(); } } averageAge = sum / count;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有