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 04 – Simple Loop

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 : 5272
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 04 – Simple Loop  Empty
Bài gửiTiêu đề: Assignment 04 – Simple Loop    Assignment 04 – Simple Loop  I_icon_minitime29/3/2011, 18:56

Assignment 04 – Simple Loop  Titleb10 29/3/2011, 18:56 » Assignment 04 – Simple Loop Assignment 04 – Simple Loop  Titleb12
Bài 1:
Code:
/*
 * @author Trinh Thai Anh 
 * T094054
 */
public class cAss04Pro01_SimplePower_T094054 {
   /**
    * @param args
    */
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      // use for to print out <i> <i*i> <i*i*i>
      for (int i = 0, j = i * i, k = i * i * i; i < 31; i++, j = i * i, k = i
            * i * i) {
         System.out.print(i + "\t" + j);// print out <i> and <i*i>
         System.out.println("\t" + k);// print out <i*i*i>
      }// end for
   }// end main function
}// end class
Bài 2:
Code:
/*
 * @author Trinh Thai Anh 
 * T094054
 */
public class cAss04Pro02_SimpleInvestment_T094054 {
   /**
    * @param args
    */
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      // print out the header
      System.out
            .println("Invest: 1000\tInterest rate: 14,4%\tUnit: 1000 VND");
      System.out.println("\tMonth\tIncome\tProfit");
      // use for to calculate income and profit
      for (int i = 1; i <= 12; i++) {
         double income = 1000;
         double profit;
         for (int j = 1; j <= i; j++)
            income = income * 1.012;
         profit = income - 1000;
         // print out income and profit
         System.out.println("\t" + i + "\t" + (int) income + "\t"
               + (int) profit);
      }// end for
      System.out.println("For more information, pls. contact with T094054.");
   }// end main function
}// end class
Bài 3:
Code:
/*
 * @author Trinh Thai Anh 
 * T094054
 */
public class cAss04Pro03_VluKfc_T094054 {
   /**
    * @param args
    */
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      // print out lines 01 and 02
      System.out.println("COMBO 01");
      System.out.println("STT" + "\t" + "So Luong" + "\t" + "Don Gia" + "\t"
            + "Thanh Tien");
      // use for to calculate if customers purchase 1-15 servings
      for (int i = 1; i <= 15; i++) {
         // print out lines 03 - 17
         System.out.println(i + "\t" + i + "\t" + "\t" + 41500 + "\t" + i
               * 41500);
      }// end for
         // use for to calculate if customers purchase 16-40 servings
      for (int j = 16; j <= 40; j++) {
         // print out lines 18 – 42
         System.out.println(j + "\t" + j + "\t" + "\t" + 39500 + "\t" + j
               * 39500);
      }// end for
         // use for to calculate if customers purchase more than 41 servings
      int k = 41;
      // print out line 43
      System.out.println(k + "\t" + ">40" + "\t" + "\t" + 35000);
   }// end main function
}// end class
Bài 4:
Code:
/*
 * @author Trinh Thai Anh 
 * T094054
 */
public class cAss04Pro04_TaxiPrice_T094054 {
   /**
    * @param args
    */
   @SuppressWarnings("unused")
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      // declare variable
      int i, j, k;
      // print out the header
      System.out.println("VLU-Taxi:Vios Prices");
      System.out.println("\t" + "Km" + "\t" + "Total" + "\t" + "Amount");
      // use for to calculate Taxi price from 1km to 20km
      for (int i1 = 1; i1 <= 20; i1++) {
         // print out line 03 - 22
         System.out.println("\t" + i1 + "\t" + 13500 * i1 + "\t" + "VND");
      }// end for
         // use for to calculate Taxi price from 21km to 50km
      for (int j1 = 21; j1 <= 50; j1++) {
         // print out line 23 - 52
         System.out.println("\t" + j1 + "\t"
               + (20 * 13500 + (j1 - 20) * 12500) + "\t" + "VND");
      }// end for
         // use for to calculate Taxi price from 51km to 80km
      for (int k1 = 51; k1 <= 80; k1++) {
         // print out line 53 - 82
         System.out.println("\t" + k1 + "\t" + (645000 + (k1 - 50) * 11000)
               + "\t" + "VND");
      }// end for
         // print out the contact contents
      System.out.println("\t" + "From 81 km, the price: 10000vnd / 1km.");
      System.out.println("Call (083)VLUTAXI for more information.");
   }// end main function
}// end class
Bài 5:
Code:
import javax.swing.JFrame;
import java.awt.*;

/*
 * @author Trinh Thai Anh 
 * T094054
 */
@SuppressWarnings("serial")
public class cAss04Pro05_ClosedGrid_T094054 extends JFrame {
   // constructor
   public cAss04Pro05_ClosedGrid_T094054() {
      // set size width=400, height= 300
      setSize(400, 300);
      // set background color
      setBackground(Color.white);
      // set title
      setTitle("Closed Grid");
   }

   // paint function
   public void paint(Graphics g) {
      // set grids color
      g.setColor(Color.GRAY);
      for (int i = 40; i <= 240; i += 20) {
         g.drawLine(40, i, 340, i);// use for to draw vertical lines
      }// end for
      for (int j = 40; j <= 340; j += 20) {
         g.drawLine(j, 40, j, 240);// use for to draw horizontal lines
      }// end for
   }// end paint

   /**
    * @paramargs
    */
   public static void main(String[] args) {
      // TODOAuto-generated method stub
      // declare the window
      cAss04Pro05_ClosedGrid_T094054 mainWindow = new cAss04Pro05_ClosedGrid_T094054();
      // set status as closing
      mainWindow.setDefaultCloseOperation(EXIT_ON_CLOSE);
      // show the window
      mainWindow.setVisible(true);
   }// end main function
}// end class
Bài 6:
Code:
import javax.swing.JFrame;
import java.awt.*;

/*
 * @author Trinh Thai Anh 
 * T094054
 */
@SuppressWarnings("serial")
public class cAss04Pro06_OpenedGrid_T094054 extends JFrame {
   // constructor
   public cAss04Pro06_OpenedGrid_T094054() {
      // set size width=400, height= 300
      setSize(400, 300);
      // set background color
      setBackground(Color.white);
      // set title
      setTitle("Opened Grid");
   }

   // paint function
   public void paint(Graphics g) {
      // set grids color
      g.setColor(Color.BLUE);
      for (int i = 60; i <= 220; i += 20) {
         g.drawLine(40, i, 340, i);// use for to draw vertical lines
      }// end for
      for (int j = 60; j <= 320; j += 20) {
         g.drawLine(j, 40, j, 240);// use for to draw horizontal lines
      }// end for
   }// end paint

   /**
    * @paramargs
    */
   public static void main(String[] args) {
      // TODOAuto-generated method stub
      // declare the window
      cAss04Pro06_OpenedGrid_T094054 mainWindow = new cAss04Pro06_OpenedGrid_T094054();
      // set status as closing
      mainWindow.setDefaultCloseOperation(EXIT_ON_CLOSE);
      // show the window
      mainWindow.setVisible(true);
   }// end main function
}// end class
Bài 7:
Code:
/*
 * @author Trinh Thai Anh 
 * T094054
 */
public class cAss04Pro07_PowerOfTwo_T094054 {
   /**
    * @param args
    */
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      // print out the header
      System.out.println("Power of two");
      System.out.println("\t" + "#no" + "\t" + "n" + "\t" + "2^n");
      // declare variable
      double s = 0.5;
      // use for to calculate exponentiation
      for (int i = 0; i <= 20; i++) {
         s = s * 2;
         // print out line 03 - 23
         System.out.println("\t" + (i + 1) + "\t" + i + "\t" + (int) s);
      }// end for
         // print out the last line
      System.out.print("Example of LOOP!");
   }// end main function
}// end class
Bài 8:
Code:
/*
 * @author Trinh Thai Anh 
 * T094054
 */
public class cAss04Pro08_Rectangle_T094054 {
   /**
    * @param args
    */
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      // print line i (i=1, .. ,10)
      for (int i = 0; i < 10; i++)
      // use for to print out the "*" in 1 line
      {
         for (int j = 1; j <= 20; j++)
            System.out.print("*");
         System.out.println("");
      }// end for
   }// end main function
}// end class
Bài 9:
Code:
/*
 * @author Trinh Thai Anh 
 * T094054
 */
public class cAss04Pro09_TwinAngle_T094054 {
   /**
    * @param args
    */
   public static void main(String[] args) {
      // TODO Auto-generated method stub
      for (int i = 1; i <= 20; i++) {// print line i (i=1, .. ,10)
         for (int j = 1; j <= i; j++) {// use for to print out the "*" in
                                 // left side
            System.out.print("*");
         }// end for
         for (int k = 40 - 2 * i; k > 0; k--) {// use for to print out the
                                       // spaces in 1 line
            System.out.print(" ");
         }// end for
         for (int j = 1; j <= i; j++) {// use for to print out the "*" in
                                 // right side
            System.out.print("*");
         }// end for
         System.out.println("");
      }// end for
   }// end main function
}// end class

Bài 10:
Code:
import java.util.Scanner;

/*
 * @author Trinh Thai Anh 
 * T094054
 */
public class cAss04Pro10_AllAreMine_T094054 {
   /**
    * @param args
    */
   public static void main(String[] args) {
      Scanner in = new Scanner(System.in);
      // TODO Auto-generated method stub
      // declare variable
      int n = 0;
      System.out.print("Nhap n: ");// input n
      n = in.nextInt();
      System.out.print("Cac so tu 1 den " + n + ": ");
      // use for to calculate numbers from 1 to n
      for (int i = 1; i <= n; i++) {
         System.out.print(i + "-");// print out the result
      }// end for
   }// end main function
}// end class



Assignment 04 – Simple Loop  Border11 Assignment 04 – Simple Loop  Border14
Về Đầu Trang Go down
https://nhom1.forum-viet.com
 

Assignment 04 – Simple Loop

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

 Similar topics

-
» Assignment 06 – Loop And Array
» Assignment 08: Methods
» Assignment 02 – Simple Computing and Converter
» Assignment 09: Classes
» Assignment 01 – HelloWorld
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