search

Home  >  Q&A  >  body text

Xiaofang’s question about saving money

class WhileDemo2{ public static void main(String[] args){ double dayMoney=2.5; double daySum=0; int dayCount=1; double result=100; while(daySum<=result){ daySum =dayMoney; if (dayCount%5==0){ daySum-=6; } dayCount ; System.out.println(daySum); System.out.println(dayCount); } }}Why is the result 75 days different from the teacher’s

wsws902 days ago1129

reply all(2)I'll reply

  • autoload

    autoload2022-07-01 09:07:59

    Caution while condition

    image.png

    reply
    1
  • ws

    Thank you, teacher, for answering your questions. That’s great! ! ! !

    ws · 2022-07-01 12:19:21
  • Cancelreply