Danh mục

Bài tập java về nhập liệu từ bàn phím

Số trang: 12      Loại file: doc      Dung lượng: 47.50 KB      Lượt xem: 24      Lượt tải: 0    
Hoai.2512

Phí tải xuống: 4,000 VND Tải xuống file đầy đủ (12 trang) 0
Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Tài liệu tham khảo cho các bạn sinh viên học chuyên ngành ôn thi tốt Java
Nội dung trích xuất từ tài liệu:
Bài tập java về nhập liệu từ bàn phímBài tập java về nhập liệu từ bàn phím!1. Viết chương trình kiểm tra giá trị một số N nhập vào là chẵn hay lẻ.import java.io.*;public class ChanLe {public static void main (String[] args) throws Exception{int n;BufferedReader in = new BufferedReader(new InputStreamReader(System.in));System.out.print(Nhap n can xem chan hay le: );n=Integer.parseInt(in.readLine());if(n%2==0){System.out.print(so :+n+la so chan);}else{System.out.print(so : +n+ la so le);}}}[=========> Bổ sung bài viết import java.io.*;public class InSoNguyen {public static void main (String[] args) throws Exception {int so;System.out.println(cac so nguyen tu 0 den 10 tru cac so 3,4,5 la: );for(int i=0;i Bổ sung bài viết n=Integer.parseInt(in.readLine());for(int i=1;i Bổ sung bài viết s=s+(1/tong);}System.out.println(Vay tong cua +n+co dang 1+(1/(1+2!)+..+1/(1+2!+3!)la: ===>+s);}}[=========> Bổ sung bài viết int n;System.out.print(Nhap n de xem no co phai la so ng to khong:);n=sc.nextInt();if((n==0)|(n==1)){System.out.print(so +n+ khong phai la so ng to);}if(n==2){System.out.print(so 2 la so ng to);}if((n>2)&&(n%2==0)){System.out.print(so +n+khong phai la so ngyen to );}else{System.out.print(so +n+la so nguyen to );}}}[=========> Bổ sung bài viết int tongchan=0,tongle=0;BufferedReader in= new BufferedReader (new InputStreamReader(System.in));System.out.print(Nhap so phan tu trong mang n:);n=Integer.parseInt(in.readLine());int a[]=new int[n];int i;for(i=0;iif(a[i] Bổ sung bài viết }}}[=========> Bổ sung bài viết System.out.print(Nhap a[+i+]: );a[i]=Integer.parseInt(in.readLine());}tangdan(a,n);System.out.print(Day so tang dan: );for(i=1;i{kt1=1;}else{kt1=0;i=n;}}if(kt==1){System.out.print(Day so vua nhap co gia tri tang dan );}if(kt1==1){System.out.print(Day so vua nhap co gia tri giam dan);}if((kt==0)&&(kt1==0)){System.out.print(Day vua nhap khong co thu tu );}}}[=========> Bổ sung bài viết }[=========> Bổ sung bài viết }for(i=1;i Bổ sung bài viết

Tài liệu được xem nhiều: