Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Arrays;
- public class scores {
- public static void main(String[] args) {
- double[] scores = new double[30];
- double[] credithour = new double[30];
- double total = 0;
- int register;
- double gpa;
- String[] course = new String[30];
- System.out.print(" how many courses did you register ? : ");
- Scanner input4 = new Scanner(System.in) ;
- register = input4.nextInt();
- if (register > 2 && register < 18){
- System.out.println (" You registered "+register+" courses !!!");
- Scanner input = new Scanner(System.in);
- System.out.println("Please enter " + register + " course names :::"+"\t");
- for (int i = 0; i<register; i++){
- System.out.print (" Enter course " + (i+1) + ":");
- course[i] = input.nextLine();
- }
- System.out.println("Thank you ");
- System.out.println (" Now please enter the scores for each course !!!");
- for (int i = 0; i< register; i++) {
- System.out.println (" Enter score for " + course[i] + ":");
- scores[i] = input.nextInt();
- }
- System.out.print (" Now enter their credit values !!!");
- for (int i = 0; i< register; i++) {
- System.out.println (" Enter credit value for " + course[i] + ":");
- credithour[i] = input.nextInt();
- // System.out.println (" done :");
- }
- input.close();
- input4.close();
- //////
- for(int i=0;i<register;i++){
- if ( scores[i] >= 90 ){
- System.out.println( " Your grade is A " );
- scores[i]= 4.0;
- System.out.println( scores[i] );
- }
- else
- if ( scores[i] >= 80 ){
- System.out.println( " Your grade is B " );
- scores[i]= 3.5;}
- else
- if ( scores[i] >= 70 ){
- System.out.println( " Your grade is C " );
- scores[i]= 3.0;}
- else
- if ( scores[i] >= 60 ){
- System.out.println( " Your grade is D " );
- scores[i]= 2.5;}
- else{
- System.out.println( " Your grade is F " );
- scores[i]= 2.0;
- }
- }
- for (int i=0;i<register;i++){
- total +=credithour[i]*scores[i];
- System.out.println (credithour[i]+"hours " + scores[i] + "score");
- }
- double cpa = 0;
- for (int i=0;i<register;i++){
- cpa +=credithour[i];
- }
- System.out.println (" You total is : " + total);
- gpa = total /cpa;
- System.out.println (" You GPA for this semester is : " + gpa);
- System.out.println (" Coursname \t Score \t credithour");
- for(int i=0;i<register;i++){
- System.out.println (" " + course[i] + "\t" + " " +scores[i] + "\t" + " " + credithour[i] );
- }
Add Comment
Please, Sign In to add comment