0

Solution the exercice

Write a program that keeps reading input from the user as long as the number entered is odd. Once the loop ends due to an even number entered (other than 0), your program should output the minimum odd number entered, the maximum odd number and whether the sum resulting of all these numbers is divisible by the last even number entered or not. Sample run: Enter odd integers (even to stop): 11 9 15 5 3 4 Minimum odd number: 3; Maximum odd number: 15 Sum: 43. 43 is not divisible by 4

28th Jan 2020, 6:41 PM
Hilal J. Masri
Hilal J. Masri - avatar
15 Respuestas
+ 7
Steps to follow- 1) Declare an ArrayList. 2) Use a while loop and take the input from the user as long as the given conditions are met. 3) Sort the ArrayList. 4) Print the first element of the list to get your answer.
28th Jan 2020, 7:05 PM
Avinesh
Avinesh - avatar
+ 3
How much do I set the size of the array
28th Jan 2020, 6:57 PM
Hilal J. Masri
Hilal J. Masri - avatar
+ 2
You can check if a number is even by using a divisio operator then checking if it equal to 0. But you should also check if number is 0 first.
28th Jan 2020, 6:51 PM
Gevork Bagratyan
+ 2
Use a dynamic array like ArrayList.
28th Jan 2020, 7:00 PM
Avinesh
Avinesh - avatar
+ 1
I want help with this sentence once the loop ends due to an even number entered (other than 0)
28th Jan 2020, 6:50 PM
Hilal J. Masri
Hilal J. Masri - avatar
+ 1
Thank you
28th Jan 2020, 6:54 PM
Hilal J. Masri
Hilal J. Masri - avatar
+ 1
Ok thank you
28th Jan 2020, 7:03 PM
Hilal J. Masri
Hilal J. Masri - avatar
+ 1
ok
29th Jan 2020, 6:16 AM
Tadiwa Tawana
Tadiwa Tawana - avatar
0
Please attach your attempt to the post. This is not a place to have other people do your work. Try to solve your assignment, then ask for help on sections you're stuck on.
28th Jan 2020, 6:45 PM
Gevork Bagratyan
0
Please
28th Jan 2020, 6:50 PM
Hilal J. Masri
Hilal J. Masri - avatar
0
So kinda like if(num % 2 == 0 && num != 0)
28th Jan 2020, 6:52 PM
Gevork Bagratyan
0
Size arry ??
28th Jan 2020, 6:55 PM
Hilal J. Masri
Hilal J. Masri - avatar
0
?
28th Jan 2020, 6:56 PM
Gevork Bagratyan
0
You wouldnt have to use an array. Unless it is specified to. (Whoops I didn't read the assignment thoroughly)
28th Jan 2020, 6:59 PM
Gevork Bagratyan
0
I want help in exercise 4.3 comments problem in Java plz help in solution
21st Feb 2022, 2:19 PM
Good Vibes 👍
Good Vibes 👍 - avatar