Arama butonu
Bu konudaki kullanıcılar: 1 misafir
5
Cevap
313
Tıklama
0
Öne Çıkarma
Java Yardım
C
10 yıl
Teğmen
Konu Sahibi

Merhabalar,

Genellikle db üzerinde çalışıyorum. Java'da çok bilgim yok ama öğrenmek istiyorum. şöyle bişey yapmam gerekiyor şimdi, bunun için interface ya da abstract kullanmak lazım galiba ama tam beceremedim o kısmı. Yardımcı olacak var mıdır?

Bi tane mağaza var, müşteriler belli günlerde alışveriş yaparsa indirim kazanıyor. Sallıyorum salı günü %10, pazartesi günü %40, pazartesi indirim yok.

senaryo:
müşteri mağazaya giriyor. ->Magaza shop = new Magaza();
sonra alışverişini yapıyor. ->shop.setUrun("Gomlek"); shop.setFiyat(100);
alışveriş yaptığı güne göre indirim uygulanıp fiyat düşecek.
son olarak işlemini bitirir. -> shop.odeme();



L
10 yıl
Teğmen

Aşağıdaki fonksiyonla günü alırsın hangi güne ne kadar indirim istiyorsan basit bir if yapısı ile istediğini yapabilirsin.

public static String dayOfWeek() { 
Calendar cal = Calendar.getInstance();
java.util.Date now = new java.util.Date(cal.getTimeInMillis());
String dayName = String.format("%tA", now);
return dayName;
}



M
10 yıl
Yarbay

Date now = new Date(); // Bugunun tarihini alalim.
shop.applyDiscount(Discount.get(now)); // Discount class'i verilen tarihe gore static bir constructor sunsun. Istedigimiz "shop" a , istedigimiz zamanin indirimini uygulayabiliriz.
----------------------------
class Discount(){

private static final Discount MONDAY = new Discount(....) // Tum gunleri temsil eden discount'lar final ve private.


private Discount ( BigDecimal amount ) {} // Constructor private ve parasal islemler BigDecimal class'i ile halledilmeli.


public static Discount getDiscount(Date date){

Burada verilen date , in dustugu gune gore ilgili static final class'i return edilir. Discount'un immutable olmasi gerekiyor, ya da yeni bir Discount objesi "Defensive Copy" yapilarak return edilmeli.


}
}
----------------------

Ek bir not, su anda bulundugumuz gunu Calendar.getInstance.getField(Calendar.DAY_OF_WEEK) seklinde alabilirsin. Syntax'i kafadan yazdim ama bu sekilde olmali. 0 ' in Pazar gununu temsil ediyor olmasi lazim. Onlara bakarsin.



< Bu ileti tablet sürüm kullanılarak atıldı >

D
9 yıl
Er

bunu yapabilecek birileri var mı acil lütfen

(75 points) 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

(25 points) Write a Java method named maskVowels that takes a String as a parameter and returns a String. The method counts the vowels of the given String. The number will be the mask key. Each letter should be changed according to mask key. You need to increase the ASCII of this letters by the mask key (you may need a helper function to count vowels).

Example01:

“Hello” → Mask: 2

“Jgnnq”

Example02:

“cam” → Mask: 1

“dbn”


Bu mesaja 1 cevap geldi.
B
9 yıl
Yarbay

quote:

Orijinalden alıntı: duru801801


bunu yapabilecek birileri var mı acil lütfen

(75 points) 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

(25 points) Write a Java method named maskVowels that takes a String as a parameter and returns a String. The method counts the vowels of the given String. The number will be the mask key. Each letter should be changed according to mask key. You need to increase the ASCII of this letters by the mask key (you may need a helper function to count vowels).

Example01:

“Hello” › Mask: 2

“Jgnnq”

Example02:

“cam” › Mask: 1

“dbn”


1. sorunun aynısını bugün biri daha sordu cevabını şu konuya yazdım. https://forum.donanimhaber.com/fb.asp?m=122796606

2. soruyu da çözerim şimdi

İkiniz de aynı okuldasınız sanırım hangi okul?



B
9 yıl
Yarbay


import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.println("Enter the word: ");

String word = scanner.next();

System.out.println(maskVowels(word));

}

private static String maskVowels(String word) {

int vowels = 0;

for (int i = 0; i < word.length(); i++)

if (word.charAt(i) == 'a' || word.charAt(i) == 'e' || word.charAt(i) == 'i' || word.charAt(i) == 'o' || word.charAt(i) == 'u')

vowels++;

char[] new_word = word.toCharArray();

for (int i = 0; i < word.length(); i++)

new_word[i] += vowels;

return String.valueOf(new_word);

}
}


@duru801801





< Bu mesaj bu kişi tarafından değiştirildi Booker DeWitt -- 25 Aralık 2016; 16:25:44 >


Bu mesajda bahsedilenler: @duru801801
DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.