<delect id="sj01t"></delect>
  1. <em id="sj01t"><label id="sj01t"></label></em>
  2. <div id="sj01t"></div>
    1. <em id="sj01t"></em>

            <div id="sj01t"></div>
            java語言

            java實驗報告

            時間:2025-04-24 04:01:48 java語言 我要投稿

            java實驗報告

              實驗一

            java實驗報告

              1.編寫一個程序,在屏幕上顯示如下信息:

              **************************

              welcome<你的名字>

              **************************

              想一想:怎樣讓用戶在運行程序的時候指定“你的名字”

              public class Experiment1_1 {

              public static void main(String[] args) {

              System.out.println( "*************************");

              System.out.println( " welcome 寧System.out.println( "*************************");

              }

              }

              2. 寫一個Java程序打印出下列信息:

              姓名

              性別

              年齡

              學號

              系和專業

              興趣愛好

              public clas

              s Experiment1_2 {

              public static void main(String args[])

              {

              System.out.println("姓名");

              System.out.println("性別");

              System.out.println("年齡");

              System.out.println("學號");

              System.out.println("系和專業");

              System.out.println("興趣愛好");

              }

              }

              3.編寫一個程序,使用while循環計算1~1000之間能被3和7同時整除的整數之和 public class Experiment1_3 {

              public static void main(String[] args) {

              int i=1;

              int sum=0;

              while(i<=1000)

              {

              if(i%7==0&&i%3==0)

              sum+=i;

              i++;

              }

              System.out.print("sum="+sum);

              }

              ");

              }

              實驗二

              1. 有一函數,編寫一個程序,從鍵盤輸入一個x值,程序輸出y的值

              x012x y1x0

              x0 13x

              import java.util.Scanner;

              public class Experiment2_1 {

              public static void main(String[] args) {

              Scanner reader=new Scanner(System.in); int x=reader.nextInt();

              if(x<0)

              System.out.println(-1+2*x);

              else if(x==0)

              System.out.println(-1);

              else

              System.out.println(-1+3*x);

              }

              }

              2. 編寫一個程序,使用for循環計算8+88+888+8888+…的前十項之和

              要求:在上述程序中設置斷點和觀察點進行單步調試

              public class Experiment2_2 {

              public static void main(String[] args) {

              int sum=0;

              int temp=8;

              for(int i=1;i<=10;i++)

              {

              sum+=temp;

              temp=temp*10+8;

              }

              System.out.println("sum="+sum);

              }

              }

              3. 利用for循環打印 9*9 表

              1*1=1

              1*2=2 2*2=4

              1*3=3 2*3=6 3*3=9

              1*4=4 2*4=8 3*4=12 4*4=16

              1*5=5 2*5=10 3*5=15 4*5=20 5*5=25

              1*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36

              1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49

              1*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64

              1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81 要求:對上述程序中的方法和語句加上注釋

              public class Experiment2_3 {

              public static void main(String[] args) {

              for(int i=1;i<10;i++)

              {

              for(int j=1;j<=i;j++)

              System.out.printf("%4d*%d=%d",i,j,j*i); System.out.print(' ');

              }

              }

              }

              4. 從鍵盤輸入一個百分制的成績,輸出相應的等級。

              90分以上 A級

              80~89 B級

              70~79 C級

              60~69 D級

              60分以下 E級

              import java.util.Scanner;

              public class Experiment2_4 {

              public static void main(String[] args) {

              Scanner reader=new Scanner(System.in);

              int score=reader.nextInt();

              switch(score/10)

              {

              case 10:

              case 9:

              System.out.println("A");break;

              case 8:

              System.out.println("B");break;

              case 7:

              System.out.println("C");break;

              case 6:

              System.out.println("D");break;

              case 5:

              case 4:

              case 3:

              case 2:

              case 1:

              case 0:

              System.out.println("E");break;

              }

              }

              }

              實驗三

              1.實驗要求:

              使用Java編寫控制臺應用程序

              用戶從鍵盤輸入月份,使用switch語句輸出該月份的天數

              如果輸入月份為2月份,則程序提示讓用戶輸入年份,再輸出結果

              import java.util.*;

              public class Experiment3_1 {

              public static void main(String args[]){

              Scanner reader=new Scanner(System.in);

              int month,day,year;

              System.out.printf("請用戶輸入月份:");

              month=reader.nextInt();

              switch(month){

              case 1:

              case 3:

              case 5:

              case 7:

              case 8:

              case 10:

              case 12:System.out.println("本月31天");break; case 4:

              case 6:

              case 9:

              case 11:System.out.println("本月30天");break;case 2:

              System.out.printf("請用戶輸入年份:");

              year=reader.nextInt();

              if(year%4==0&&year%100!=0||year%400==0){ System.out.printf("本月29天");

              }

              else{

              System.out.printf("本月28天");

              }

              }

              }

              }

              2.實驗要求:

              使用Java編寫控制臺應用程序

              輸出九九乘法表

              public class Experiment3_2 {

              public static void main(String args[]){

              for(int i=1;i<=9;i++){

              for(int j=1;j<=i;j++){

              System.out.printf("%d*%d=%-2d",j,i,i*j); System.out.printf(" ");

              }

              System.out.printf(" ");

              }

              System.out.printf(" ");

              for(int i=1;i<=9;i++){

              for(int j=1;j<=9;j++){

              System.out.printf("%d*%d=%-2d",i,j,i*j); System.out.printf(" ");

              }

              System.out.printf(" ");

              }

              System.out.printf(" ");

              for(int i=1;i<=9;i++){

              for(int j=i;j<=9;j++){

              System.out.printf("%d*%d=%-2d",i,j,i*j); System.out.printf(" ");

              }

              System.out.printf(" ");

              for(int k=1;k<=i;k++){

              System.out.printf(" ");

              }

              }

              }

              }

              3實驗要求:

              使用Java編寫控制臺應用程序

              計算有固定收入的黨員每月所交納的黨費。月工資收入400元及以下者,交

              納月工資總額的0.5%;月工資收入401~600元者,交納月工資總額的1%;月工資收入601~800元者,交納月工資總額的1.5%;月工資收入801~1500元者,交納月工資總額的2%;月工資收入1500元以上者,交納月工資總額的3%;

              import java.util.Scanner;

              public class Experiment3_3 {

              public static void main(String args[]){

              Scanner reader=new Scanner(System.in);

              System.out.println("請用戶輸入工資:");

              float salary;

              float money = 0;

              salary=reader.nextFloat();

              if(salary<=400&&salary>=0){

              money=(float) (salary*0.005);

              篇二:JAVA實驗報告參考答案-九院版喔

              實 驗 報 告

              院

              系:

              專 業:

              班 級:

              任課教師:

              實 驗 報 告

              院(系):信息學院 課程名稱:JAVA程序設計日期:

              實 驗 報 告

              院(系):信息學院 課程名稱:JAVA程序設計日期:

              篇三:JAVA 實驗報告

              學 生 實 驗 報 告

              學 院: 用友軟件學院

              課程名稱: Java程序設計

              專業班級:軟件工程B01班

              姓 名:尚麗娟

              學 號:0088234

              學生實驗報告(一)

              一、實驗綜述

              1、實驗目的及要求

              實驗目的:

              1. 學習數據表示、運算符和表達式;

              2. 認識Java的基本數據類型;

              3. 養成良好的程序調試和編程風格。

              試驗要求:

              編寫程序,讀入0到1000的一個整數并將其各位數字之和賦值給一個整數。如,整數932各位數字之和為14。

              2、實驗儀器、設備或軟件

              1. 個人計算機PC;

              2. Eclipse編程環境。

              二、實驗過程(實驗步驟、記錄、數據、分析)

              (1) 步驟一

              1.打開eclipse,點擊文件,新建一個名為1的項目,在新建一個名為Package的包,然后在新建一個名為Exercise1的類。然后在代碼輸入框輸入代碼

              package Package;

              import javax.swing.JOptionPane;

              public class Exercis1 {

              /**

              * @param args

              */

              public static void main(String[] args) {

              // TODO 自動生成方法存根

              String numberString=JOptionPane.showInputDialog(null,

              "Enter a number between 0 and 1000",

              "Number Input",JOptionPane.QUESTION_MESSAGE);

              int number=Integer.parseInt(numberString);

              int firstNumber=number/100;

              int secondNumber=number/10%10;

              int thirdNumber=number%10;

              int sum=firstNumber+secondNumber+thirdNumber;

              System.out.println("The sum is"+sum);

              System.exit(0);

              }

              }

              (2) 步驟二

              點擊運行,會出現以下輸入框,我們輸入923.

              在控制臺得到的結果如下:

              三、結論

              1、實驗結果

              能成功運行,沒有錯誤,并且會看到輸入框,并且在輸入框中輸入數字后,運行結果會在控制臺中顯示出正確的結果。截圖吐下

              2、分析討論

              1.是實驗中,用Java編譯出這個程序,相比以前學習使用C++編譯一個程序,JAVA更容易上手,更人性化。

              2.在實驗過程中,如果代碼出現語法等錯誤,代碼下面會顯紅線,讓我們清晰的了解到哪里出錯。

              3.在實驗過程中,一定要注意單詞的首字母是否要大寫,在類名每個單詞的首字母都要大寫,常量中的所有字母都要大寫。在實驗中,常常因為這些命名會出現問題。

              4.在實驗過程中,例如這個程序一定要明白它的邏輯再來輸入代碼,不然很容易出現邏輯錯誤。

              5.在實驗中,JOptionPane.showInputDialog這個方法從輸入對話框得到輸入從控制臺輸出。。如果我們可以不用這個進行輸入的話,我們可以直接用Scanner里創建對象進行輸入。

              6.在實驗過程中我們還要注意到,輸入對話框返回的輸入是一個字符串,想要獲得熟知必須把字符串轉化為數字值,如果不這樣做,我們得到的結果就是“923”是一個字符串。所以我們一定要有一個方法使其轉換為數字例如以下代碼:

              int number=Integer.parseInt(numberString)

              四、指導教師評語及成績:

              評語:

              該實驗步驟正確。程序設計較合理,結果正確。實驗報告格式正確,文檔規范,

              描述較清晰。掌握了運用該知識的方法與技能,較好地完成了實驗任務。達到實驗目的。

              成績:82  指導教師簽名:xxx

              批閱日期:201x-3-15

            【java實驗報告】相關文章:

            關于java實驗報告模板03-09

            java語言程序設計實驗報告10篇12-08

            Java與Java web的區別01-30

            淺談Java語言與Java 技術03-28

            Java與Java web有什么不同04-16

            java教程之Java編程基礎04-18

            談Java語言與Java技術的介紹02-19

            Java 繼承07-04

            java講解06-23

            <delect id="sj01t"></delect>
            1. <em id="sj01t"><label id="sj01t"></label></em>
            2. <div id="sj01t"></div>
              1. <em id="sj01t"></em>

                      <div id="sj01t"></div>
                      黄色视频在线观看