Herkese merhaba arkadaşlar biz okulda java acm(library) öğreniyoruz. Ve hoca bununla ilgili her hafta ödev veriyor. Ben ödevi anlasamda bir türlü istenilen sonuca ulaşamiyorum. Acaba java konusunda bilgi sahibi olan arkadaşlar yardımcı olabilirler mi şimdiden teşekkürler.
soru su;
Write a Java method named checkValidity which takes an integer array as parameter and returns boolean value. The method/s must complete following tasks:
(a) The array length should be 16 at most. So you need to check the length first. If the length of the array is odd, then you should double the number that in even index (index starts at 1). If the length of the array is even, then you should double the odd index’s number (index starts at 0).
Example01: {1,2,3,4}
Example02: {3,5,7,2,2}
Example03: {0,0,0,5,7,0}
(b) If the number that is doubled, is greater than 9, you should replace the number with the sum of the digits (you may need a helper function to sum digits).
{0,0,0,5,5,0} → 5+5 = 10 d-) Finally, divide this sum with 10 and if the remainder is equal to zero, this number is valid (true), otherwise not a valid number (false).
false
false
true
DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.
Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.
Bilgi Universitesi odevi. Odevleri kendiniz yapin. Takildiginiz zaman da asistaniniza, hocaniza sorun. Cevap alamazsaniz gelin burada sorun. Sonra kendinize nasil "muhendis" diyeceksiniz ?
soru su;
Write a Java method named checkValidity which takes an integer array as parameter and
returns boolean value. The method/s must complete following tasks:
(a) The array length should be 16 at most. So you need to check the length first. If the length of the array
is odd, then you should double the number that in even index (index starts at 1). If the length of the
array is even, then you should double the odd index’s number (index starts at 0).
Example01: {1,2,3,4}
Example02: {3,5,7,2,2}
Example03: {0,0,0,5,7,0}
(b) If the number that is doubled, is greater than 9, you should replace the number with the sum of the
digits (you may need a helper function to sum digits).
{1,2,3,4} → {2,2,6,4} //no need to digitsum
{3,5,7,2,2} → {3,1,7,4,2} //5*2=10 digitsum=1
{0,0,0,5,7,0} → {0,0,0,5,5,0} // 7*2 = 14 digitsum= 5
(c) After that sum all the numbers.
{2,2,6,4}→ 2+2+6+4 =14
{3,1,7,4,2} → 3+1+7+4+2 = 17
{0,0,0,5,5,0} → 5+5 = 10
d-) Finally, divide this sum with 10 and if the remainder is equal to zero, this number is valid (true),
otherwise not a valid number (false).
false
false
true
DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.
Üye Ol Şimdi DeğilÜye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.