搜索
熱搜: 活動 交友 discuz
查看: 2180|回復: 0
打印 上一主題 下一主題

[教學] IVE Lab 7-4 Sample

[複製鏈接]
跳轉到指定樓層
1#
發表於 2007-7-27 21:15:28 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
import javax.swing.*;

public class multi_table {
  
  static String input_string;
  static int input_int;
  static int cross, roll, num;
  static String space = "";
  static String result = "";
  
  public static void main(String[] args) {
   
    input_string = JOptionPane.showInputDialog(null, "Input a number of range", "The calculation of multiplication",
                                               JOptionPane.QUESTION_MESSAGE);
   
    input_int = Integer.parseInt(input_string);
   
    System.out.println("Multiplication Table\n");
    result = "";
    for (cross = 0; cross <= input_int; cross++) {
      num = cross;
      if (num < 10) {
        space = "  ";
      } else {
        space = " ";
      }
      if (num == 0) {
        result += "   ";
      } else {
        result += num + space;
      }
     
    }
    System.out.print(result + "\n");
   
    for (cross = 1; cross <= input_int; cross++) {
      result = "";
      for(roll = 1; roll <= input_int; roll++) {
        num = cross * roll;
        if (num < 10) {
          space = "  ";
        } else {
          space = " ";
        }
        result += space + num;
      }
      result += "\n";
      System.out.print(cross + result);
    }
  }
}
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

本論壇為非營利之網路平台,所有文章內容均為網友自行發表,不代表論壇立場!若涉及侵權、違法等情事,請告知版主處理。


Page Rank Check

廣告刊登  |   交換連結  |   贊助我們  |   服務條款  |   免責聲明  |   客服中心  |   中央分站

手機版|中央論壇

GMT+8, 2026-5-3 03:17 , Processed in 0.033282 second(s), 17 queries .

Powered by Discuz!

© 2005-2015 Copyrights. Set by YIDAS

快速回復 返回頂部 返回列表