Can someone check my code? I need to make sure it works.
System.out.println(" Give me five numbers.");
for (int i=1; i<=5; i++){
System.out.println("Enter a number this is number this is number " +i+":");
list1.add(input.nextInt());
}
System.out.println("this is the list" + list1);
Integer smallest = list1.get(0);
Integer largest = 0;
for (Integer e : list1){
if (e > largest){
largest=e;
}
if (e < smallest){
smallest=e;
}
}
System.out.println("smallest values "+ smallest);
System.out.println("largest values "+ largest);
ArrayList even = new ArrayList ();
ArrayList odd = new ArrayList ();
int sum = 0;
for(int depo : list1) {
if(depo % 2 == 0) {
even.add (depo);
}
else{ odd.add (depo);
}
sum += depo;
}
System.out.println("even values "+ even);
System.out.println("odd values "+ odd );
System.out.println("total values "+ sum);
}
}
https://replit.com/join/ttumvtjy-shunaco
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
TETSXPREME:
how are we supposed to do that ?
Shuki:
Click the link
imqwerty:
paste it somewhere where we don't have to login in to see it
use: https://p.ip.fi/
Shuki:
blocked
imqwerty:
💀
Still Need Help?
Join the QuestionCove community and study together with friends!
Sign Up
Shuki:
yeps, but thanks. Im sorry I didnt know you would have to login in