Let yosh = prompt("Yoshingizni kiriting:")
Download 17.35 Kb.
|
Java 1-amaliy Diyorbek
1.Foydalanuvchidan yoshni so’raydigan dasturni tuzing. Yosh 50 dan yuqori bo’lsa, dastur “Siz kattasiz” deb chiqarib berishi kerak. Yosh 50 dan past bo’lsa “Siz yoshsiz” deb chiqarib berishi kerak. let yosh = prompt("Yoshingizni kiriting:"); if (yosh > 50) { console.log(" Siz kattasiz"); } else { console.log("Siz yoshsiz"); } Somsani narxini so’raydigan dastur. Narx 35000 dan yuqori bo’lsa - dastur “qimmat” deb chiqarib bersin. 35000 dan arzon bo’lsa - “arzon” deb chiqarib bersin. let somsa = prompt("Somsa narxini kiriting:"); if (somsa > 3500) { console.log(" qimmat"); } else { console.log("arzon"); } 2.Foydalanuvchi yoshini kiritish kerak. Yoshi 0 dan 30 gacha bo’lsa, unga “yoshsiz” deb yozing. Yoshi 30 dan 60 gacha bo’lsa, unga “kattasiz” deb yozing. Yoshi 60 dan yuqori bo’lsa, unga siz qarisiz deb yozing. let yosh=prompt("yoshni kiriting: ") if(0 console.log("Yoshsiz") } else if(30 console.log("Kattasiz") } else { console.log("Qarisiz") } 3.Foydalanuvchidan ismini so’rang. Ismi “Ali” bo’lsa, unga “Salom og’a” deb yozing. Ismi “Ahmad” bo’lsa, unga “Ko’rinmayapsan do’stim, nima qilyapsan?” deb yozing. let ism=prompt("Ismingizni kiriting: ") if(ism=='Ali') { console.log("Salom og'a") } else if(ism=='Ahmad') { console.log("Ko'rinmayapsan og'a nima qilayapsan") } 4.Foydalanuvchidan oyligini so’rang. Va soliq bilan yoki soliqsiz hisoblash kerakligini so’rang. So’ng yillik YIG’ADIGAN pulini hisoblab bering (soliq bilan yoki soliqsiz). Foydalanuvchi topgan pulidan 90% sarflaydi - shuni inobatga oling. let oylik = prompt("Oyligingizni kiriting : ") let foiz = prompt("Soliq bilan yoki soliqsiz : ") if(foiz == "soliq"){ oylik = oylik * 0.1 } let yillik = (oylik - oylik * 0.9) * 12; console.log("Yillik yig'ilgan summa : ",yillik) 5.Olmazor, Avtovokzal va Stadion orqali yuradigan avtobuslarni chiqaradigan dasturni tuzing. Foydalanuvchi Olmazorni tanlasa 33 deb chiqaring. Avtovokzal – 1, 16. Stadion orqali - 212, 246, 10, 23 Bajarilishi: let avtobus=prompt("Avtobusni kiriting: ") let avtobuslar = ['Olmazor','Avtovokzal','Stadion'] if (avtobuslar.includes(avtobus)=='Olmazor') { console.log(" 33"); } else if(avtobuslar.includes(avtobus)=='Avtovokzal') { console.log("1, 16"); } else { console.log("212, 246, 10, 23") } 6.Narxlar: Somsa: 30000, Palov: 25000 Sarimsoq kg: 20000 Foydalanuvchi unda bor pulini kiritsin. Va molni tanlasin. Puli yetsa - “sotib oldingiz” deb chiqaring. Puli yetmasa - “uzr, pul yetmadi” deb yozing. let Somsa = 30000 let Palov = 25000 let Sarimsoq = 20000 let pul = prompt("Pulingizni kiriting : ") let maxsult = prompt("Maxsultni tanlang: [Somsa, Palov,Sarimsoq] : ") if(maxsult == "Somsa" && Somsa <= pul){ console.log("Sotib oldingiz") } else if(maxsult == "Palov" && Palov <= pul){ console.log("Sotib oldingiz") } else if(maxsult == "Sarimsoq" && Sarimsoq <= pul){ console.log("Sotib oldingiz") } else { console.log("uzr, pul yetmadi") } 7. Internet do’kon tuzing. 10 ta mahsolot bo’lsin (10 ta checkbox). Har bittasini sotib olsa bo’ladi. Va qariyalarga (70<) 10% chegirma beriladi. Hamda kamida 5 ta mahsulot sotib olgan odamga 15% chegirma beriladi. Let maxsulotlar = ["Telfon","Kompyuter","Tv","Koylak","Shim","Tufli","Paypoq","Daftar","Qalam","Moshin"] console.log(maxsulotlar) let harid = prompt("Hurmatli mijoz nima sotib olmoqchisiz : ") let yosh = prompt("Yoshingizni kiriting : ") if(yosh > 70){ console.log("Sizga 10% chegirma berildi") } else { let n = prompt("Bu nechinchi haridingiz : ") if(n >= 5){ console.log("Sizga 15% chegirma berildi") } else { console.log("Haridingizdan minnatdormiz!!") } } 8.Ismlar arrayi ichidan promptdan so’ralayotgan ism bo’lsa ha bunday ism bor, agar bo’lmasa afsus bubday ism yo’q degan yozuv chiqarilishi kerak const ism= prompt('Ismni kiriting:') const ismlar=['Asadbek', 'Sanjar', "Ulug`bek"] if(ismlar.includes(ism)) { console.log(`Ha ${ism} bor`) } else { console.log(`Afsus ${ism} yo'q`) } Download 17.35 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling