---小考內容複習---

package chap1;

import java.io.InputStreamReader;
import java.io.*;
 public class quit2{
  public static void main(String args[])throws Exception{
 BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
 
 String subname1,subname2,subname3,subname4,subname5,number="4020Q090",name="李依靜";
 subname1="國文";subname2="英文";subname3="程設";subname4="管理學";subname5="統計學";
 int chicredit=3,engcredit=2,procredit=3,mancredit=3,stacredit=3,totalcredit;
 int chiscore,engscore,proscore,manscore,stascore,total; float avgscore;
 
 System.out.println("請輸入國文成績");
 chiscore=Integer.parseInt(br.readLine());
 System.out.println("請輸入英文成績");
 engscore=Integer.parseInt(br.readLine());
 System.out.println("請輸入程設成績");
 proscore=Integer.parseInt(br.readLine());
 System.out.println("請輸入管理學成績");
 manscore=Integer.parseInt(br.readLine());
 System.out.println("請輸入統計學成績");
 stascore=Integer.parseInt(br.readLine());
 
 total=chiscore*chicredit+engscore*engcredit+proscore*procredit+manscore*mancredit+
 stascore*stacredit;
 totalcredit=chicredit+engcredit+procredit+mancredit+stacredit;
 avgscore=(float)total/totalcredit;
 
 System.out.println("我的姓名:"+name+"\t"+"我的學號:"+number);
 System.out.println("科目:"+"\t"+subname1+"\t"+subname2+"\t"+subname3+"\t"+subname4+"\t"+subname5);
 System.out.println("學分數"+"\t"+chicredit+"\t"+engcredit+"\t"+procredit+"\t"+mancredit+"\t"+stacredit);
 System.out.println("成績:"+"\t"+chiscore+"\t"+engscore+"\t"+proscore+"\t"+manscore+"\t"+stascore);
 System.out.println("加權平均分數="+avgscore);
 
  }
}

 ---課程內容---

 package chap5;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class test1028 {
 public static void main(String args[])throws Exception {
 int num ;
 BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
 System.out.println("請輸入數值");
 num=Integer.parseInt(br.readLine());
 if(num%2==0)//  關係運算式   求餘數
 System.out.println("num=為偶數"); 
 else
 System.out.println(num+"不是偶數");
 
 } 
}
 

 

---

 package chap5;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class test1028 {
 public static void main(String args[])throws Exception {
 int num ;
 BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
 String pointer="y";
 
 while(pointer=="y"){
 System.out.println("請輸入數值");
 num=Integer.parseInt(br.readLine());
 if(num%2==0)//  關係運算式   求餘數
 System.out.println(num+"'是'偶數");
 else
 System.out.println(num+"是奇數");
 
 } 
 }
}

 

---

package chap5;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class test1028 {
 public static void main(String args[])throws Exception {
 int num ;
 BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
 boolean doit= true;

 while(doit){
  System.out.println("請輸入數值");
 num=Integer.parseInt(br.readLine());
 if(num%2==0)//  關係運算式   求餘數
  System.out.println(num+"是偶數");
 else
  System.out.println(num+"是奇數");
 } 
 }
}

 

 

 

玥君 發表在 痞客邦 PIXNET 留言(0) 人氣()