package chap1;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class test1216 {
 public static void main(String args[])throws Exception{
  BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
  
  String subjectname[] = new String [5];
  int score[] =new int [5];
  int credit[] =new int [5]; 
 
 

 System.out.println("請輸入科目名稱");
 subjectname[0]=br.readLine();
 System.out.println("請輸入成績");
 score[0]=Integer.parseInt(br.readLine());
 System.out.println("請輸入學分數");
 credit[0]=Integer.parseInt(br.readLine());
 System.out.println("科目名稱:"+subjectname[0]+"\t成績:"+score[0]+"\t學分數:"+credit[0]);

 }}

---

 

package chap1;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class test1216 {
 public static void main(String args[])throws Exception{
  BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
  
  String subjectname[] = new String [5];
  int score[] =new int [5];
  int credit[] =new int [5]; 
 
  for(int i=0;i<5;i++){
 System.out.println("請輸入科目名稱");
 subjectname[i]=br.readLine();
 System.out.println("請輸入成績");
 score[i]=Integer.parseInt(br.readLine());
 System.out.println("請輸入學分數");
 credit[i]=Integer.parseInt(br.readLine());
 System.out.println("科目名稱:"+subjectname[i]+"\t成績:"+score[i]+"\t學分數:"+credit[i]);
  
  }

}}

 

---

 

package chap1;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class test1216 {
 public static void main(String args[])throws Exception{
  BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
  
  String subjectname[] = new String [5];
  int score[] =new int [5];
  int credit[] =new int [5]; 
 
  for(int i=0;i<5;i++){
 System.out.println("請輸入科目名稱");
 subjectname[i]=br.readLine();
 System.out.println("請輸入成績");
 score[i]=Integer.parseInt(br.readLine());
 System.out.println("請輸入學分數");
 credit[i]=Integer.parseInt(br.readLine());
 System.out.println("科目名稱:"+subjectname[i]+"\t成績:"+score[i]+"\t學分數:"+credit[i]);
  
  }
 
  int sum = 0 ;
  for(int i=0;i<score.length;i++)
  sum= score[0]*credit[0];
 System.out.println("加權分數:"+sum );
  }}

 ---

package chap1;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class test1216 {
 public static void main(String args[])throws Exception{
  BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
  
  String subjectname[] = new String [5];
  int score[] =new int [5];
  int credit[] =new int [5]; 
 
 for(int i=0;i<5;i++){
  System.out.println("請輸入科目名稱");
  subjectname[i]=br.readLine();
  System.out.println("請輸入成績");
  score[i]=Integer.parseInt(br.readLine());
  System.out.println("請輸入學分數");
  credit[i]=Integer.parseInt(br.readLine());
  System.out.println("科目名稱:"+subjectname[i]+"\t成績:"+score[i]+"\t學分數:"+credit[i]);
  
   }
 
 int sum = 0 ,creditsum=0;
 for(int j=0;j<score.length;j++){
  sum = sum+ score[j]*credit[j];
  System.out.println("加權分數:"+sum );
  creditsum = creditsum +credit[j];
  System.out.println("學分數加總:"+creditsum );
  }
 }}

---

 

package chap1;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class test1216 {
 public static void main(String args[])throws Exception{
  BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
  
  String subjectname[] = new String [5];
  int score[] =new int [5];
  int credit[] =new int [5]; 
 
 for(int i=0;i<5;i++){
  System.out.println("請輸入科目名稱");
  subjectname[i]=br.readLine();
  System.out.println("請輸入成績");
  score[i]=Integer.parseInt(br.readLine());
  System.out.println("請輸入學分數");
  credit[i]=Integer.parseInt(br.readLine());
  System.out.println("科目名稱:"+subjectname[i]+"\t成績:"+score[i]+"\t學分數:"+credit[i]);
  
   }
 
 int sum = 0 ,creditsum=0,avg;
 for(int j=0;j<score.length;j++){
  sum = sum+ score[j]*credit[j];
  System.out.println("加權分數:"+sum );
  creditsum = creditsum +credit[j];
  System.out.println("學分數加總:"+creditsum );
  }

avg=sum/creditsum;

System.out.println("加權平均:"+avg);
 }}

 

 

 

 

 

 

 

 

 

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