1K subscribers
1.77K photos
420 videos
678 files
3.85K links
Download Telegram
#savol
Berilgan so'zni toLowerCase(), toUpperCase() method larni ishlatmagan holda katta harflardan kichik harflarga, kichik harflardan katta harflarga o'tkazuvchi funksiya yozing?

#javob
#lowerCase
#upperCase
Java dasturlash tilida

public class LowerAndUpper {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
char[] str = scanner.next().toCharArray();
System.out.println(myLowerCase(str));
System.out.println(myUpperCase(str));
}

private static char[] myLowerCase(char[] chars) {
char[] newArray = new char[chars.length];
for (int i = 0; i < chars.length; i++) {
if (chars[i] >= 97 && chars[i] <= 122) {
newArray[i] = chars[i];
} else {
newArray[i] = (char) (chars[i] + 32);
}
}
chars = newArray;
return chars;
}

private static char[] myUpperCase(char[] chars) {
char[] newArray = new char[chars.length];
for (int i = 0; i < chars.length; i++) {
if (chars[i] >= 65 && chars[i] <= 90) {
newArray[i] = chars[i];
} else {
newArray[i] = (char) (chars[i] - 32);
}
}
chars = newArray;
return chars;
}
}

Telegram | Viktorina bot | Portfolio
3👍2🤓21🥰1👏1👨‍💻1
✔️ #javob_java_if_21

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("x = ");
int x = scanner.nextInt();
System.out.print("y = ");
int y = scanner.nextInt();
if (x == 0 && y == 0) {
System.out.println(0);
} else if (x > 0 && y == 0) {
System.out.println(1);
} else if (x == 0 && y > 0) {
System.out.println(2);
} else {
System.out.println(3);
}
}

Telegram | Viktorina bot | Portfolio
Please open Telegram to view this post
VIEW IN TELEGRAM
👍3❤‍🔥1👏1
Please open Telegram to view this post
VIEW IN TELEGRAM
❤‍🔥11👍1
#savol
Berilgan so'zni toLowerCase(), toUpperCase() method larni ishlatmagan holda katta harflardan kichik harflarga, kichik harflardan katta harflarga o'tkazuvchi funksiya yozing?

#javob
#lowerCase
#upperCase
Kotlin dasturlash tilida

fun main() {
val scanner = Scanner(System.in)
val str = scanner.next().toCharArray()
println(myLowerCase(str))
println(myUpperCase(str))
}

fun myLowerCase(chars: CharArray): CharArray {
var chars = chars
val newArray = CharArray(chars.size)
for (i in chars.indices) {
if (chars[i].toInt() in 97..122) {
newArray[i] = chars[i]
} else {
newArray[i] = (chars[i].toInt() + 32).toChar()
}
}
chars = newArray
return chars
}

fun myUpperCase(chars: CharArray): CharArray {
var chars = chars
val newArray = CharArray(chars.size)
for (i in chars.indices) {
if (chars[i].toInt() in 65..90) {
newArray[i] = chars[i]
} else {
newArray[i] = (chars[i].toInt() - 32).toChar()
}
}
chars = newArray
return chars
}

Telegram | Viktorina bot | Portfolio
2❤‍🔥1🐳1🏆1👨‍💻1
✔️ #javob_java_if_22

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("x = ");
int x = scanner.nextInt();
System.out.print("y = ");
int y = scanner.nextInt();
if (x > 0) {
if (y > 0) {
System.out.println(1);
} else {
System.out.println(4);
}
} else if (x < 0) {
if (y > 0) {
System.out.println(2);
} else {
System.out.println(3);
}
}
}

Telegram | Viktorina bot | Portfolio
Please open Telegram to view this post
VIEW IN TELEGRAM
👍21❤‍🔥1👏1💯1
Please open Telegram to view this post
VIEW IN TELEGRAM
👨‍💻2👍1🔥1🏆1🤓1
#savol

#javob
#for17
Java dasturlash tilida

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("n = ");
int n = scanner.nextInt();
System.out.print("a = ");
float a = scanner.nextFloat();
int s = 1;
int t = 1;
for (int i = 0; i < n; i++) {
t *= a;
s += t;
}
System.out.println(s);
}

Telegram | Viktorina bot | Portfolio
2🏆2👍1🔥1👏1
✔️ #javob_java_if_23

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int x4 = 0, y4 = 0;
System.out.print("x1 = ");
int x1 = scanner.nextInt();
System.out.print("y1 = ");
int y1 = scanner.nextInt();
System.out.print("x2 = ");
int x2 = scanner.nextInt();
System.out.print("y2 = ");
int y2 = scanner.nextInt();
System.out.print("x3 = ");
int x3 = scanner.nextInt();
System.out.print("y3 = ");
int y3 = scanner.nextInt();

if (x1 == x2) {
x4 = x3;
} else if (x1 == x3) {
x4 = x2;
} else if (x2 == x3) {
x4 = x1;
}

if (y1 == y2) {
y4 = y3;
} else if (y1 == y3) {
y4 = y2;
} else if (y2 == y3) {
y4 = y1;
}
System.out.println(x4 + " " + y4);
}

Telegram | Viktorina bot | Portfolio
Please open Telegram to view this post
VIEW IN TELEGRAM
👍21👏1🐳1🏆1👨‍💻1
Please open Telegram to view this post
VIEW IN TELEGRAM
👍21❤‍🔥1🔥1💯1🏆1🤓1
Please open Telegram to view this post
VIEW IN TELEGRAM
👍3🔥1🥰1👌1🏆1
✔️ #javob_java_if_24

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("x = ");
float x = scanner.nextFloat();
if (x > 0) {
System.out.println(2 * Math.sin(x));
} else {
System.out.println(x-6);
}
}

Telegram | Viktorina bot | Portfolio
Please open Telegram to view this post
VIEW IN TELEGRAM
👍3🤩1👌1🤓1👨‍💻1
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥2👍1🥰1👏1🐳1
#savol
isDigit nomli funksiyasi yarating va parametrga String ko'rinishida satr berilgan bo'lsin. Satr tarkibida raqam bor yoki yo'qligi topuvchi dastur tuzing. Agar satr tarkibida son bo'lsa true, aks holda false qiymat qaytaring?

#javob
#isDigit
Java dasturlash tilida

public class isDigitFunction {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println(isDigit(scanner.nextLine()));
}

private static boolean isDigit(String str){
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
if (ch >= 48 && ch <= 57){
return true;
}
}
return false;
}
}

Telegram | Viktorina bot | Portfolio
🔥2👍1👏1🏆1👨‍💻1
✔️ #javob_java_if_25

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("x = ");
float x = scanner.nextFloat();
if (x < -2 || x > 2) {
System.out.println(2 * x);
} else {
System.out.println(-3 * x);
}
}

Telegram | Viktorina bot | Portfolio
Please open Telegram to view this post
VIEW IN TELEGRAM
👍4👏2❤‍🔥1🏆1👨‍💻1
Please open Telegram to view this post
VIEW IN TELEGRAM
👍4🔥2❤‍🔥11🐳1🏆1
✔️ #javob_java_if_26

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("x = ");
float x = scanner.nextFloat();
if (x <= 0) {
System.out.println(-x);
} else if (x > 0 && x < 2) {
System.out.println(x * x);
} else {
System.out.println(4);
}
}

Telegram | Viktorina bot | Portfolio
Please open Telegram to view this post
VIEW IN TELEGRAM
👍4🤩21👏1🐳1💯1🏆1👨‍💻1
Please open Telegram to view this post
VIEW IN TELEGRAM
3❤‍🔥2🔥1👏1🐳1🏆1
✔️ #javob_java_if_27

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("x = ");
float x = scanner.nextFloat();
if (x < 0) {
System.out.println(0);
} else if ((int) x % 2 == 0) {
System.out.println(1);
} else {
System.out.println(-1);
}
}

Telegram | Viktorina bot | Portfolio
Please open Telegram to view this post
VIEW IN TELEGRAM
👍2❤‍🔥1🔥1👏1🏆1
Please open Telegram to view this post
VIEW IN TELEGRAM
👍31🔥1👏1🏆1
✔️ #javob_java_if_28

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("n = ");
int n = scanner.nextInt();
if (n % 4 == 0 && n % 100 != 0 || n % 400 == 0) {
System.out.println(366);
} else
System.out.println(365);
}

Telegram | Viktorina bot | Portfolio
Please open Telegram to view this post
VIEW IN TELEGRAM
2❤‍🔥1🔥1💯1👨‍💻1
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥31👍1🥰1👏1