Фильтр публикаций


📊




package finalLab;

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

Patient pat1 = new Patient();
System.out.print("Enter patient's name: ");
pat1.setName(input.nextLine());
System.out.print("Enter patient's room number: ");
pat1.setRoomNumber(input.nextInt());

System.out.print("How many medicines? ");
int n = input.nextInt();
input.nextLine();

String[] meds = new String[n];
System.out.println("Enter medicines' names: ");
for(int i = 0;i < n;i++){
meds[i] = input.nextLine();
}
pat1.setMedicine(meds);

pat1.printInfo();
}
}

class Patient {
private String name; // اسم المريض
private int roomNumber; // رقم الغرفة
String[] medicine; // أدوية خاصة بالمريض

public void setName(String name) {
this.name = name;
}

public void setRoomNumber(int roomNumber) {
this.roomNumber = roomNumber;
}

public void setMedicine(String[] medicine) {
this.medicine = medicine;
}

public String getName() {
return name;
}

public int getRoomNumber() {
return roomNumber;
}

public String[] getMedicine() {
return medicine;
}

public void printInfo() {
System.out.println("Name: " + getName());
System.out.println("Room number: " + getRoomNumber());
System.out.println("Medicines: ");;
for(int i = 0;i < medicine.length;i++){
System.out.print(medicine[i].toLowerCase() + " ");
}
}
}


import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int option;
User myUser = new User();
System.out.print("Enter username: ");
myUser.setUserName(input.nextLine());

System.out.print("Enter password: ");
myUser.setPassword(input.nextLine());

System.out.print("Enter email: ");
myUser.setEmail(input.nextLine());

do {
System.out.println("Choose what to do : ");
System.out.println("1. Print current information.");
System.out.println("2. Change password.");
System.out.println("3. Exit.");
System.out.print("Your option: ");
option = input.nextInt();
switch(option) {
case 1: System.out.println("Your user's information: ");
myUser.printInfo();
break;
case 2: myUser.changePassword();
break;
}
} while (option != 3);
}
}
class User {
private String userName;
private String password;
private String email;

public void setUserName(String userName) {
this.userName = userName;
}
public void setPassword(String password) {
this.password = password;
}
public void setEmail(String email) {
this.email = email;
}

public String getUserName() {
return userName;
}
public String getPassword() {
return password;
}
public String getEmail() {
return email;
}

public void printInfo() {
System.out.println("Username : " + getUserName());
System.out.println("Password : " + getPassword());
System.out.println("Email : " + getEmail());
}


public void changePassword() {
Scanner input = new Scanner(System.in);
String newPassword;
System.out.println("Enter new password: ");
newPassword = input.nextLine();
while (newPassword.equals(password)) {
System.out.println("Error. Enter a new password: ");
newPassword = input.nextLine();
}
password = newPassword;
}
}


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

int a = 10;
System.out.println(a++*a++);

}
}


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

int a = 0;
if(a==1);{
System.out.println("Sun");
}

}
}


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

int a = 5;
a +=5;

switch(a){
case 5: System.out.print("5");break;
case 10: System.out.print("10");
default: System.out.print("0");
}

}
}


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

int a = 10;
System.out.println(++a++);

}
}


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

for (int i = 0; i < 5; i++); {
System.out.println("Instagram");
}

}
}
Instagram ekranga necha marotaba chiqadi ?


public class Test {
    public static void main(String[] args{

     for(int i = 0; i < 5; ){
     System.out.println("Hello");
     }

  }
}


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

      int i = 0;
      for (;  i < 5; i++) {
          System.out.print(i + " ");
      }

  }
}


public class Test{

public static void main(String[] args) {
    String str1 = "hello";
    String str2 = "world";
    
System.out.println(
combineStrings(str1, str2)
);

    }

  static String combineStrings(String s1, String s2) {
     return
s1.substring(0, s1.length() / 2) +
s2 +
s1.substring(s1.length() / 2);

    }

}
Kod ishga tushirilsa natijada nima ko'rinadi ?


Every challenge in life makes you stronger. The greatest enemy is the lack of self-belief. You can overcome any obstacle as long as you trust in your dreams.📖




5k








My new project
( O'zbekcha Tarjimon 2024)



Показано 20 последних публикаций.