coding with ☕️
2 subscribers
262 photos
14 videos
11 files
165 links
Anwendungsentwicklung
Download Telegram
// Primitive = oddiy qiymat, to‘g‘ridan-to‘g‘ri xotirada (stack) saqlanadi

// Reference = xotiradagi manzil (stack), u esa heap dagi obyektga ishora qiladi

// 🧠 Primitive vs 🧠 Reference

// int string
// double array
// char object
// boolean
import java.util.Scanner;

public class Main {
public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

String item;
double price;
int quantitiy;
char currency = '$';
double total;

System.out.print("What item would you like to buy?: ");
item = scanner.nextLine();

System.out.print("What is the price for each?: ");
price = scanner.nextDouble();

System.out.print("How many would you like?: ");
quantitiy = scanner.nextInt();

total = price * quantitiy;
System.out.println("\nYou have bought " + quantitiy + " " + item + "/s");
System.out.println("Your total is " + currency + total);

scanner.close();


}
}
if (age >= 0 && age <= 18) {
alert("You are a kid, get your passport and learn something!");
} else if (age >= 19 && age <= 50) {
alert("You should work!");
} else if (age >= 51 && age <= 59) {
alert("You will retire soon!");
} else if (age >= 60 && age <= 150) {
alert("You are likely a pensioner, if you are still alive...");
} else if (age > 150) {
alert("Are you even human? ");
} else {
alert("Something went wrong!");
}


Difference between JS , C codes same syntax same Values



int main() {
int age;

printf("Enter your age: ");
scanf("%d", &age);

if (age > 0 && age <= 18) {
printf("You are a kid, get your pass up and learn something!\n");
} else if (age > 19 && age <= 50) {
printf("You are ought to work!\n");
} else if (age > 51 && age <= 59) {
printf("You will get retired soon!\n");
} else if (age > 60 && age <= 150) {
printf("You are likely to be pensioner, if you are still alive...\n");
} else if (age > 151) {
printf("You are alive?\n");
} else {
printf("Something went wrong!\n");
}

return 0;



Difference between JavaScript, C, Java codes same syntax same Values!


import java.util.Scanner;

public class Main {
public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);


int age;

System.out.print("Enter your age: ");
age = scanner.nextInt();

if (age >= 65) {

System.out.println("You are a senior! ");
}else if (age >= 18) {

System.out.println("You are an adult! ");
} else if (age < 0) {

System.out.println("You haven't been born yet! ");

} else if (age == 0) {
System.out.println("You are a baby! ");

} else {

System.out.println("You are a child! ");
}

scanner.close();

}
}
if (age >= 0 && age <= 18) {
alert("You are a kid, get your passport and learn something!");
} else if (age >= 19 && age <= 50) {
alert("You should work!");
} else if (age >= 51 && age <= 59) {
alert("You will retire soon!");
} else if (age >= 60 && age <= 150) {
alert("You are likely a pensioner, if you are still alive...");
} else if (age > 150) {
alert("Are you even human? ");
} else {
alert("Something went wrong!");
}
import java.util.Scanner;

public class Main {
public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

String name;
int age;
boolean isStudent;

System.out.print("Enter your name: ");
name = scanner.nextLine();

System.out.print("Enter your age: ");
age = scanner.nextInt();

System.out.print("Are you a student (true/false): ");
isStudent = scanner.nextBoolean();

//GROUP 1

if (name.isEmpty()){
System.out.println("You didn't enter your name! ");
}else {
System.out.println("Hello " + name + "!");
}

//GROUP 2

if (age >= 65) {

System.out.println("You are a senior! ");
}else if (age >= 18) {

System.out.println("You are an adult! ");
} else if (age < 0) {

System.out.println("You haven't been born yet! ");

} else if (age == 0) {
System.out.println("You are a baby! ");

} else {

System.out.println("You are a child! ");
}

//GROUP 3

if (isStudent) {

System.out.println("You are a student! ");
}else {
System.out.println("You are a NOT a student! ");
}

scanner.close();

}
}
import java.util.Random;

public class Main {
public static void main(String[] args) {

Random random = new Random();

boolean isHeads;

isHeads = random.nextBoolean();

if (isHeads) {

System.out.println("Heads");
}else {
System.out.println("Tails");

}

}
}
public class Main {
public static void main(String[] args) {

double result;

result = Math.pow(2, 5);
result = Math.abs(-5);
result = Math.sqrt(9);
result = Math.round(3.14);
result = Math.ceil(3.14);
result = Math.floor(3.99);
result = Math.max(10, 20);
result = Math.min(10, 20);


System.out.println(result);


}
}
public class Main {
public static void main(String[] args) {

double result;

result = Math.pow(2, 5); // 2 ni 5-darajaga ko‘tar degani 2 ni 5 martta ko'paytiradi degani
result = Math.abs(-5); // Manfiy sonni musbat qilib beradi -5 -> 5
result = Math.sqrt(9); // Kvadrat ildizini top 9 ning ildizi -> 3
result = Math.round(3.14); // oddiy yaxlitlash 3.14 -> 4 ni butun qilib qaytaradi
result = Math.ceil(3.14); // yuqoriga yaxlitlaydi 3.14 -> 4
result = Math.floor(3.99); // pastga yaxlitlaydi 3.99 -> 3
result = Math.max(10, 20); // Ikkita sondan kattasini oladi
result = Math.min(10, 20); // Ikkita sondan kichkinasini oladi


System.out.println(result);


}
}
import java.util.Scanner;

public class Main {
public static void main(String[] args) {

// HYPOTENUSE c = Math.sqrt(a + b);

Scanner scanner = new Scanner(System.in);

double a;
double b;
double c;

System.out.print("Enter the length of side A: ");
a = scanner.nextDouble();

System.out.print("Enter the length of side B: ");
b = scanner.nextDouble();

c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));

System.out.println("The hypotenuse (side c) is: " + c + " cm" );


scanner.close();
}
}
import java.util.Scanner;

public class Main {
public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

double radius;
double circumference;
double area;
double volume;


System.out.print("Enter the radius: ");
radius = scanner.nextDouble();

circumference = 2 * Math.PI * radius;
area = Math.pow(radius, 2);
volume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3);


System.out.printf("The circumference is: %.1fcm\n", circumference);
System.out.printf("The area is: %.1fcm²\n", area);
System.out.printf("The volume is: %.1fcm³\n", volume);

scanner.close();
}
}
public class Main {
public static void main(String[] args) {

// printf() = is a method used to format output

// %[flags][width][precision][specifier-character]


String name = "Spongebob";
char firstLetter = 'S';
int age = 30;
double height = 60.5;
boolean isEmployed = true;

System.out.printf("Hello %s\n", name );
System.out.printf("Your name starts with a %c\n", firstLetter);
System.out.printf("You are %d years old\n", age);
System.out.printf("You are %f inches tall\n", height);
System.out.printf("Emloyed: %b\n", isEmployed);

System.out.printf("%s is %d years old", name, age);
}
}
Forwarded from Webstrom_Tech Family🔥
Java Interview Q&A🔥

https://coderssection.com/Java-Q&A

👆👆👆👆👆
import  java.util.Scanner;
public class Main {
public static void main(String[] args) {

// Compound interest calculator

Scanner scanner = new Scanner(System.in);

double principal;
double rate;
int timesCompounded;
int years;
double amount;

System.out.print("Enter the principal amount: ");
principal = scanner.nextDouble();

System.out.print("Enter the interest rate (in %): ");
rate = scanner.nextDouble() / 100;


System.out.print("Enter the # of times compounded per years: ");
timesCompounded = scanner.nextInt();

System.out.print("Enter the # of years: ");
years = scanner.nextInt();

amount = principal * Math.pow(1 + rate / timesCompounded, timesCompounded * years);

System.out.printf("The amount after %d years is $%.2f", years, amount);


scanner.close();
}
}
public class Main {
public static void main(String[] args) {


String name = "Password";

// int length = name.length();
// char letter = name.charAt(0);
// int index = name.indexOf(" ");
// int lastIndex = name.lastIndexOf("o");

// name = name.toUpperCase();
// name = name.toUpperCase();
// name = name.trim();
// name = name.replace("o", "a");

// if(name.isEmpty()) {
// System.out.println("Your name is Empty");
// }else {
//
// System.out.println(" Hello" + name);
// }


// if(name.contains(" ")) {
//
// System.out.println("Your name contains a space");
// }else {
// System.out.println("Your name doesn't contain any spaces");
// }

if (name.equalsIgnoreCase("password")) {

System.out.println("Your name can't be password");
}else {

System.out.println("Hello " + name);
}

}

}
public class Main {
public static void main(String[] args) {


String txt = "Hello World";

System.out.println(txt.toUpperCase()); // HELLO WORLD
System.out.println(txt.toLowerCase()); // hello world
System.out.println(txt.length()); // 11

String text = "Please locate where locate occurs";
System.out.println(text.indexOf("locate")); // 7

String sample = "Hello";
System.out.println(sample.charAt(0)); // H
System.out.println(sample.charAt(4)); // o

String a = "Hello";
String b = "Hello";

System.out.println(a.equals(b)); // true
System.out.println(a.equalsIgnoreCase(b)); // true


String lyrc = " Hello World ";
System.out.println(lyrc.trim());

String txt1 = "Java is hard";
System.out.println(txt1.replace("hard", "easy"));

String txt2 = "backendDeveloper";

System.out.println(txt2.startsWith("back")); // true
System.out.println(txt2.endsWith("per")); // true

String txt3 = "";
System.out.println(txt3.isEmpty()); // true

String txt4 = "Microservice";
System.out.println(txt4.substring(0, 6)); // Micros


}

}
import java.util.Scanner;

public class Main {
public static void main(String[] args) {

// .substring() = A mehtod used to extract a portion of a string
// string.substring(start, end)

// .Substring() - method olib tashlaydi (0, 6) nishonovafotima24@gmail.com -> nishon

Scanner scanner = new Scanner(System.in);

String email;
String username;
String domain;

System.out.println("Enter your email: ");

email = scanner.nextLine();

if (email.contains("@")) {
username = email.substring(0, email.indexOf("@"));
domain = email.substring(email.indexOf("@") + 1);

System.out.println(username);
System.out.println(domain);

}else {
System.out.println("Emails must contains @");
}

scanner.close();
}

}