Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

loop error

 
patricia feaster
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy - am in the process of creating a program where a user enters the number of people in their family. The loop is suppose to loop the number of member in their family.. I got it to loop but it gives me a error stating that the int needs to be a boolean.. i am not really sure what it asking me.

for(int count = 1; count < familyMembers; count--)
System.out.println("enter member one's first name, last name, age, weight, height.");

firstName1 = keyboard.next();
lastName1 = keyboard.next();
age1 = keyboard.nextInt();
weight1 = keyboard.nextInt();
height1 = keyboard.nextInt();

if(count = 2)
System.out.println("enter member two's first name, last name, age, weight, height.");

firstName2 = keyboard.next();
lastName2 = keyboard.next();
age2 = keyboard.nextInt();
weight2 = keyboard.nextInt();
height2 = keyboard.nextInt();

I did that all the way to six.. we have not covered arrays so I do not think i can work ahead.

the whole program is to take all family info and avgerage out the age, weight, height; tell who is the oldest, tallest, & fatest.
I could send what I have thus far.. i think its about 1/2 done, but its due by friday. thank you much for your time and I look forward to hearing from you.

VR

P.feaste
 
Mirai Chelean
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by patricia feaster:
for(int count = 1; count < familyMembers; count--)


Are you sure is count--? If it is like this, the count will never reach number higher than its first initiate.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12266
36
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you need

if (count == 2)

a single "=" is assigning the value 2 to your variable count, not testing for equality.

Once you get this fixed, you're probably gonna see a few other errors, but we can fix those as you come to them.
[ November 29, 2005: Message edited by: fred rosenberger ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic