K16T1 Nhóm 1
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.


Hãy tưởng tượng, chúng ta đang cùng ở trên một con thuyền, tất cả đều phải cùng chèo để đưa con thuyền đến đích!
 
Trang ChínhGalleryLatest imagesTìm kiếmĐăng kýĐăng Nhập

Thông báo mới nhất, click vào để xem chi tiết: Đăng kí thành viên nhóm network!

Nhạc
Latest topics
» Assignment 02: Simple Calculating
by cambeme 18/10/2011, 23:50

» CHƯƠNG V: HỌC THUYẾT GIÁ TRỊ THẶNG DƯ - Trang 47-hết
by anhkhoamc083 5/10/2011, 08:51

» Bài tập SwingDemo
by cambeme 16/9/2011, 12:22

» ass3 cau 2
by nguyentam 29/5/2011, 10:46

» Assignment 09: Classes
by cambeme 27/5/2011, 17:57

» GROUP EXERCISE 03
by cambeme 24/5/2011, 18:23

» Bản kiểm điểm
by nhoc_vet 20/5/2011, 19:29

» Trình bày GROUP EXERCISE 02
by cambeme 20/5/2011, 00:01

» Khát là gì?
by cambeme 18/5/2011, 22:01

» Assignment 08: Methods
by cambeme 15/5/2011, 23:48

» GROUP EXERCISE 02
by cambeme 11/5/2011, 22:14

» Website nhóm 1
by cambeme 10/5/2011, 20:06

» Giao diện trang chủ
by cambeme 10/5/2011, 13:00

» Cấu hình DHCP RELAY AGENT - cấp cho 2 mạng LAN
by cambeme 9/5/2011, 23:59

» Slide 16
by cambeme 6/5/2011, 23:09

» Slide 15
by cambeme 6/5/2011, 23:08

» Slide 14
by cambeme 6/5/2011, 23:07

» Assignment 07: Control and Flow
by cambeme 6/5/2011, 22:33

» Trình bày GROUP EXERCISE 01
by cambeme 6/5/2011, 00:36

» GROUP EXERCISE 01
by cambeme 5/5/2011, 15:26

» Bai 1
by nguyentam 4/5/2011, 19:24

» cau thu 3
by cambeme 1/5/2011, 15:00

» day la bai so 2
by nguyentam 30/4/2011, 17:06

» chi tiet lam DNS
by nguyentam 30/4/2011, 16:40

» Tài liệu Windows Server 2003
by cambeme 30/4/2011, 08:40

» Phần mềm
by cambeme 29/4/2011, 12:35

» Công cụ tạo máy ảo VMware Workstation 7.1.4 Build 385546 Final
by cambeme 25/4/2011, 20:08

» Đề kiểm tra giữa kỳ Network
by cambeme 15/4/2011, 11:53

» Higher Computing Systems Networking
by cambeme 15/4/2011, 10:40

» Bài tập chương 6
by cambeme 12/4/2011, 17:41

No copy

Share | 
 

 Assignment 06 – Loop And Array

Xem chủ đề cũ hơn Xem chủ đề mới hơn Go down 
Tác giảThông điệp
cambeme
Admin
Admin
cambeme


Giới tính Giới tính : Nam
Cung : Nhân Mã
Con giáp : Mùi
Bài gửi Bài gửi : 174
Điểm Điểm : 5282
Thanks Thanks : 0
Sinh nhật Sinh nhật : 05/12/1991
Ngày gia nhập Ngày gia nhập : 25/03/2011
Tuổi Tuổi : 32
Đến từ Đến từ : Thành phố Hồ Chí minh
Nghề nghiệp/ước mơ Nghề nghiệp/ước mơ : IT
Tâm trạng Tâm trạng : Hưng phắn
Châm ngôn sống Châm ngôn sống : Không có gì quý hơn hột vịt thịt kho!
Cao nhân tắt thở vô phương trị!


Assignment 06 – Loop And Array Empty
Bài gửiTiêu đề: Assignment 06 – Loop And Array   Assignment 06 – Loop And Array I_icon_minitime30/3/2011, 19:21

Assignment 06 – Loop And Array Titleb10 30/3/2011, 19:21 » Assignment 06 – Loop And Array Assignment 06 – Loop And Array Titleb12
Bài 1:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro01_SampleOfArray_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // the scanner
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        int n;
        // input n from keyboard
        System.out.print("So phan tu cua mang (nho hon 100): n=");
        n = keyboard.nextInt();
        // declare variable
        int[] arrValue = new int[n];
        for (int i = 0; i < n && n < 100; i++) {
            // input A[n] from keyboard
            System.out.print("Nhap A[" + (i + 1) + "] :");
            arrValue[i] = keyboard.nextInt();
        }// end for
        System.out.print("Thu tu nguoc lai:" + "\n");
        // use for to invert the array A[n]
        for (int j = n - 1; j >= 0 && j < 99; j--) {
            // print out the result
            System.out.println("A[" + (j + 1) + "]=" + arrValue[j]);
        }// end for
    }// end main function
}// end class
Bài 2:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro02_AverageOfArray_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // the scanner
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        int n;
        // input n from keyboard
        System.out.print("So phan tu cua mang (nho hon 100): n=");
        n = keyboard.nextInt();
        // declare variable
        int[] arrValue = new int[n];
        for (int i = 0; i < n && n < 100; i++) {
            // input A[n] from keyboard
            System.out.print("Nhap A[" + (i + 1) + "]: ");
            arrValue[i] = keyboard.nextInt();
        }// end for
            // declare variable
        double AM = 0, GM = 1, HM = 0, TSS = 0;
        // use for to calculate AM, GM and HM
        for (int j = 0; j < n; j++) {
            AM += arrValue[j];
            GM *= arrValue[j];
            HM += 1 / (double) arrValue[j];
        }// end for
            // use for to calculate TSS
        for (int k = 0; k < n; k++) {
            TSS = TSS + (arrValue[k] - AM / (double) n)
                    * (arrValue[k] - AM / (double) n);
        }// end for
            // print out the result of AM
        System.out.println("AM: " + AM / (double) n);
        // print out the result of GM
        System.out.println("GM: " + Math.pow(GM, 1 / (double) n));
        // print out the result of HM
        System.out.println("HM: " + n / (double) HM);
        // print out the result of TSS
        System.out.println("TSS: " + TSS);
    }// end main function
}// end class
Bài 3:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro03_StandardDeviation_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // the scanner
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        int n;
        // input n from keyboard
        System.out.print("So phan tu cua mang (lon hon 1 và nho hon 100): n=");
        n = keyboard.nextInt();
        // declare variable
        double[] arrValue = new double[n];
        for (int i = 0; i < n && n > 1 && n < 100; i++) {
            // input x[i] from keyboard
            System.out.print("Nhap x" + (i + 1) + ": ");
            arrValue[i] = keyboard.nextDouble();
        }// end for
            // declare variable
        double A = 0, TBC = 0, S = 0;
        // use for to calculate arithmetic mean
        for (int j = 0; j < n; j++) {
            TBC = TBC + arrValue[j] / arrValue.length;
        }// end for
            // use for to calculate standard deviation
        for (int k = 0; k < n; k++) {
            A += Math.pow((arrValue[k] - TBC), 2);
            S = Math.pow((A / (double) (n - 1)), 0.5);
        }// end for
            // print out the result
        System.out.println("S= " + S);
    }// end main function
}// end class
Bài 4:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro04_FibonacciSequence_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // the scanner
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        int n, i = 0, j;
        // input n from keyboard
        System.out.print("Nhap n: ");
        n = keyboard.nextInt();
        // declare variable
        int[] arrValue = new int[n + 1];
        // first and second element of the sequence
        arrValue[0] = 0;
        arrValue[1] = 1;
        // use for from the third element of the sequence
        for (i = 2; i < n + 1 & n > 1; i = i + 1) {
            arrValue[i] = arrValue[i - 1] + arrValue[i - 2];
        }// end for
        System.out.print("Cac phan tu theo thu tu nguoc lai:");
        // use for to calculate F[n] in descending order
        for (i = n, j = n - 1; i > -1 | j >= 0; i = i - 1, j--) {
            // print out the result
            System.out.print(" F[" + (j + 1) + "]=" + arrValue[i]);
        }// end for
    }// end main function
}// end class
Bài 5:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro05_FibonacciNumber_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // the scanner
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        int n, i = 0;
        // input n from keyboard
        System.out.print("Nhap n: ");
        n = keyboard.nextInt();
        // declare variable
        int[] arrValue = new int[n + 1];
        // first and second element of the sequence
        arrValue[0] = 0;
        arrValue[1] = 1;
        // use for from the third element of the sequence
        for (i = 2; i < n + 1 & n > 1; i = i + 1) {
            arrValue[i] = arrValue[i - 1] + arrValue[i - 2];
        }// end for
            // print out the result
        System.out.println("F[" + n + "]=" + arrValue[n]);
    }// end main function
}// end class
Bài 6:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro06_FibonacciExtension_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // the scanner
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        int a, b, n, i;
        // input a from keyboard
        System.out.print("Nhap so nguyen a=");
        a = keyboard.nextInt();
        // input b from keyboard
        System.out.print("Nhap so nguyen b=");
        b = keyboard.nextInt();
        // input n from keyboard
        System.out.print("Nhap so nguyen n=");
        n = keyboard.nextInt();
        // declare variable
        int[] arrValue = new int[n + 1];
        // first and second element of the sequence
        arrValue[0] = 0;
        arrValue[1] = 1;
        // use for to calculate F[n]
        for (i = 2; i < n + 1 & n > 1; i = i + 1) {
            arrValue[i] = a * arrValue[i - 1] + b * arrValue[i - 2];
        }// end for
            // use for to print out the result
        for (i = 0; i < n + 1; i++) {
            System.out.println("F[" + i + "]=" + arrValue[i]);
        }// end for
    }// end main function
}// end class
Bài 7:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro07_WordsList_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // the scanner
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        String a;
        // input string from keyboard
        System.out.print("Nhap chuoi:");
        a = keyboard.nextLine();
        // split the string and delete spaces
        String[] b = a.split(" ");
        // use for to count words and print out the result
        System.out.println("So tu co trong cau: " + b.length);
        System.out.println("Cac tu co trong cau theo thu tu nguoc lai:");
        // use for to invert the string and print out the result
        for (int i = b.length - 1; i >= 0; i--) {
            System.out.println(b[i]);
        }// end for
    }// end main function
}// end class
Bài 8:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro08_Dec2Bin_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        int n, i, a = 0;
        // input n from keyboard
        System.out.print("Nhap so nguyen duong n=");
        n = keyboard.nextInt();
        // declare variable
        int[] arrValue = new int[n];
        System.out.print("Binary number of " + n + " is ");
        // use for to calculate remainders when divide by 2
        for (; n > 0; a++) {
            arrValue[a] = n % 2;
            n = n / 2;
        }// end for
        for (i = a - 1; i > -1; i--) {
            System.out.print(arrValue[i]);
        }// end for
    }// end main function
}// end class
Bài 9:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro09_EPower_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        double x, phanso = 1, ketqua = 1, d = 0.000001;
        // input x from keyboard
        System.out.print("Nhap vao mot so thuc x=");
        x = keyboard.nextDouble();
        // use for to calculate the power of e
        for (double i = 1; phanso >= d || phanso <= (-d); i++) {
            phanso = phanso * (x / i);
            ketqua = ketqua + phanso;
        }// end for
            // print out the result
        System.out.println("e mu " + (double) x + " = " + ketqua);
    }// end main function
}// end class
Bài 10:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro10_SinFunction_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        double x, sin = 0, d = 0.000001;
        // input x from keyboard
        System.out.print("Nhap vao mot so thuc x=");
        // convert x to radian
        x = keyboard.nextDouble() * 0.0174532925;
        double phanso = x;
        // use for to calculate the sin of x
        for (double n = 1; (phanso >= d) || (phanso <= (-d)); n++) {
            sin = sin + phanso;
            phanso = phanso * (-x * x / ((2 * n + 1) * n * 2));
        }// end for
            // print out the result
        System.out.println("sin(" + x / 0.0174532925 + ") = " + sin);
    }// end main function
}// end class
Bài 11:
Code:
import java.util.Scanner;

/*
 * @author Anh Trinh 
 * T094054
 */
public class cAss06Pro11_CubeRoot_T094054 {
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner keyboard = new Scanner(System.in);
        // declare variable
        double x, d = 0.000001;
        // input x from keyboard
        System.out.print("Nhap vao mot so thuc x=");
        x = keyboard.nextDouble();
        // declare variable
        double cube = x / 3;
        // use for to calculate cube root of x
        for (double a = 0; (cube - a) >= d || (cube - a) <= -d;) {
            a = cube;
            cube = ((2 * cube) + x / (cube * cube)) / 3;
        }// end for
            // print out the result
        System.out.print("Can bac 3 cua " + x + " la " + cube);
    }// end main function
}// end class



Assignment 06 – Loop And Array Border11 Assignment 06 – Loop And Array Border14


Được sửa bởi cambeme ngày 8/4/2011, 23:10; sửa lần 3.
Về Đầu Trang Go down
https://nhom1.forum-viet.com
devilofdie
Moderators
Moderators


Bài gửi Bài gửi : 1
Điểm Điểm : 4792
Thanks Thanks : 0
Ngày gia nhập Ngày gia nhập : 26/03/2011


Assignment 06 – Loop And Array Empty
Bài gửiTiêu đề: Re: Assignment 06 – Loop And Array   Assignment 06 – Loop And Array I_icon_minitime30/3/2011, 20:51

Assignment 06 – Loop And Array Titleb10 30/3/2011, 20:51 » Re: Assignment 06 – Loop And Array Assignment 06 – Loop And Array Titleb12
ax, chưa gì đã post lên



Assignment 06 – Loop And Array Border11 Assignment 06 – Loop And Array Border14
Về Đầu Trang Go down
cambeme
Admin
Admin
cambeme


Giới tính Giới tính : Nam
Cung : Nhân Mã
Con giáp : Mùi
Bài gửi Bài gửi : 174
Điểm Điểm : 5282
Thanks Thanks : 0
Sinh nhật Sinh nhật : 05/12/1991
Ngày gia nhập Ngày gia nhập : 25/03/2011
Tuổi Tuổi : 32
Đến từ Đến từ : Thành phố Hồ Chí minh
Nghề nghiệp/ước mơ Nghề nghiệp/ước mơ : IT
Tâm trạng Tâm trạng : Hưng phắn
Châm ngôn sống Châm ngôn sống : Không có gì quý hơn hột vịt thịt kho!
Cao nhân tắt thở vô phương trị!


Assignment 06 – Loop And Array Empty
Bài gửiTiêu đề: Re: Assignment 06 – Loop And Array   Assignment 06 – Loop And Array I_icon_minitime30/3/2011, 21:12

Assignment 06 – Loop And Array Titleb10 30/3/2011, 21:12 » Re: Assignment 06 – Loop And Array Assignment 06 – Loop And Array Titleb12
=.= post bài mẫu thôi, mấy bài khác đợi cận ngày nộp mới post Smile)



Assignment 06 – Loop And Array Border11 Assignment 06 – Loop And Array Border14
Về Đầu Trang Go down
https://nhom1.forum-viet.com
ki-u
Moderators
Moderators
ki-u


Giới tính Giới tính : Nữ
Cung : Ma Kết
Con giáp : Thân
Bài gửi Bài gửi : 12
Điểm Điểm : 4822
Thanks Thanks : 0
Sinh nhật Sinh nhật : 25/12/1992
Ngày gia nhập Ngày gia nhập : 26/03/2011
Tuổi Tuổi : 31
Đến từ Đến từ : binh thuan
Châm ngôn sống Châm ngôn sống : ^^!


Assignment 06 – Loop And Array Empty
Bài gửiTiêu đề: Re: Assignment 06 – Loop And Array   Assignment 06 – Loop And Array I_icon_minitime30/3/2011, 23:19

Assignment 06 – Loop And Array Titleb10 30/3/2011, 23:19 » Re: Assignment 06 – Loop And Array Assignment 06 – Loop And Array Titleb12
ò, được đó chứ post hết mí bạn làm biếng cứ coppy pate la tiu lun ^^!



Assignment 06 – Loop And Array Border11 Assignment 06 – Loop And Array Border14
Về Đầu Trang Go down
https://nhom1.forum-viet.com
Sponsored content





Assignment 06 – Loop And Array Empty
Bài gửiTiêu đề: Re: Assignment 06 – Loop And Array   Assignment 06 – Loop And Array I_icon_minitime

Assignment 06 – Loop And Array Titleb10 » Re: Assignment 06 – Loop And Array Assignment 06 – Loop And Array Titleb12



Assignment 06 – Loop And Array Border11 Assignment 06 – Loop And Array Border14
Về Đầu Trang Go down
 

Assignment 06 – Loop And Array

Xem chủ đề cũ hơn Xem chủ đề mới hơn Về Đầu Trang 

 Similar topics

-
» Assignment 04 – Simple Loop
» Assignment 08: Methods
» Assignment 09: Classes
» Assignment 01 – HelloWorld
» Assignment 05 – Imazing
Trang 1 trong tổng số 1 trang

Permissions in this forum:Bạn không có quyền trả lời bài viết
K16T1 Nhóm 1 :: Các môn học :: Năm 1 :: Java-
Chuyển đến 
Đầu trang
Giữa trang
Cuối trang
Free forum | ©phpBB | Free forum support | Báo cáo lạm dụng | Thảo luận mới nhất