public class Main {
public static void main(String[] args) {
System.out.printf("Hello and welcome!");
for (int i = 1; i <= 5; i++) {
System.out.println("i = " + i);
}
}
}public class Main {
public static void main(String[] args) {
/* String ism = "Fotima";
int yosh = 20;
float baho = 4.8f;
char harf = 'F';
boolean student = true;
System.out.println(ism);
System.out.println(yosh);
System.out.println(baho);
System.out.println(harf);
System.out.println(student);*/
double price = 19.9;
double gpa = 3.9;
char garde = 'A';
char symbol = '!';
char currency = '$';
boolean isStudent = false;
boolean forSale = false;
boolean isOnline = true;
if (isStudent) {
System.out.println("You are a Student!");
}
else {
System.out.println("You are Not a Student!");
}
}
}public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
int concert = 6;
double uzs = 144000;
double usd = 12.00;
char gender = 'F';
String currency = "UZS";
boolean forSale = true;
String name = "Blackpink Concert will start!";
String on = "on";
String time = "12:00";
String week = "Tuesday";
String price = "Current price is:";
System.out.println(name + " " + on + " " + time + " " + week);
System.out.println("Concert number: " + concert);
if (forSale) {
System.out.println(price + " " + uzs + " " + currency);
} else {
System.out.println(price + " " + usd + " $");
}
}
}public class Main {
public static void main(String[] args) {
int age = 18;
int year = 2025;
System.out.println(ism);
System.out.println(yosh);
System.out.println(baho);
System.out.println(harf);
System.out.println(student);*//*
double price = 19.9;
double gpa = 3.9;
char grade = 'A';
char symbol = '!';
char currency = '$';
boolean isStudent = false;
boolean forSale = true;
boolean isOnline = true;
if (isStudent) {
System.out.println("You are a Student!");
}
else {
System.out.println("You are Not a Student!");
}
String name = "Bro Code";
String food = "Pizza";
String email = "fake123@gmail.com";
String car = "BMW";
String color = "red";
System.out.println("Your choice isa : " + color + " " + year + " " + car);
if (forSale) {
System.out.println("There is a " + car + " for sale");
}else {
System.out.println("The " + car + " is not for sale");
}
System.out.println("Your favorite food is: " + food);
System.out.println("You are " + age + " Years old");
System.out.println("Your gpa is " + gpa);
System.out.println("Your average letter grade is: " + grade);
}
} System.out.print("Enter your name: ");
String name = scanner.nextLine();
System.out.print("Enter your age: ");
int age = scanner.nextInt();
System.out.print("What is your gpa? ");
double gpa = scanner.nextDouble();
System.out.print("Are you Student? (true/false): ");
boolean isStudent = scanner.nextBoolean();
System.out.println("Hello " + name);
System.out.println("You are " + age + " years old!");
System.out.println("Your gpa is: " + gpa);
if(isStudent) {
System.out.println("Your are enrolled as a Student");
}
else {
System.out.println("Your are NOT enrolled");
}
System.out.println("Hello World");
int concert = 6;
double uzs = 144000;
double usd = 12.00;
char gender = 'F';
String currency = "UZS";
boolean forSale = true;
String name = "Blackpink Concert will start!";
String on = "on";
String time = "12:00";
String week = "Tuesday";
String price = "Current price is:";
System.out.println(name + " " + on + " " + time + " " + week);
System.out.println("Concert number: " + concert);
if (forSale) {
System.out.println(price + " " + uzs + " " + currency);
} else {
System.out.println(price + " " + usd + " $");
}
/*int items = 50;
float costPerItem = 9.99f;
float totalCost = items * costPerItem;
char currency = '$';
System.out.println("Number of items: " + items);
System.out.println("Cost per item: " + costPerItem + currency);
System.out.println("Total cost = " + totalCost + currency);import java.util.Scanner;
public class Main {
public static void main(String[] args) {
double width = 0;
double height = 0;
double area = 0;
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the width: ");
width = scanner.nextDouble();
System.out.print("Enter the height: ");
height = scanner.nextDouble();
area = width * height;
System.out.println("There is: " + area + "cm");
scanner.close();
}
}
// 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();
}
}