Skip to content

Instantly share code, notes, and snippets.

@thanhhoa214
Created September 27, 2017 12:09
Show Gist options
  • Save thanhhoa214/63919a23156b5b26f7e201bf8fef6756 to your computer and use it in GitHub Desktop.
Save thanhhoa214/63919a23156b5b26f7e201bf8fef6756 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Hello {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
//dài
System.out.println("Nhập chiều dài mảng: ");
int dai=0;
boolean flag;
do {
flag =sc.hasNextInt();
if (flag) dai=sc.nextInt();
else {
System.out.println("Try Again!");
sc.nextLine();
}
} while(!flag);
//rộng
System.out.println("Nhập chiều rộng mảng: ");
int rong=0;
do {
flag =sc.hasNextInt();
if (flag) rong=sc.nextInt();
else {
System.out.println("Try Again!");
sc.nextLine();
}
} while(!flag);
System.out.println(dai+" "+rong);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment