Question
solve in java using Eclipse
Question 6 Given a student information: Name, Surname, Quiz grade, Homework grade, Project grade, Midterm grade and Final exa
Averages of students in ascending order: Erion Sinka 51.65 Gentjana Myers 61.35 Fjorentina Rrapaj 61.75 Arlind Harper 62.90 S
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

I have written the Java code based on your requirements.

I have used BinarySearchTree to get the results that You want.

The code is working perfectly and it has no-error.

I also attached the output screen-shot that I got by running the below program.

Output:

C:Users\Public>javac test.java C:\Users\Public>java test 2 John Michael 1 2 3 4 5 Peter Michael 2 2 2 2 2 Class Average Mark

Code:

test.java :

import java.io.*;
import java.util.*;

class BST
{
   class Node
   {
       String first_name,sur_name;
       double average;
       Node left,right;
      
       public Node(String first_name,String sur_name,double average)
       {
           this.first_name=first_name;
           this.sur_name=sur_name;
           this.average=average;
           left=right=null;
       }
   }
  
   Node root;
  
   BST()
   {
       root=null;
   }
  
   void insert(String first_name,String sur_name,double average)
   {
       root=insert_data(root,first_name,sur_name,average);
   }
  
   Node insert_data(Node root,String first_name,String sur_name,double average)
   {
       if(root==null)
       {
           root=new Node(first_name,sur_name,average);
           return root;
       }
      
       if(average < root.average)
       {
           root.left=insert_data(root.left,first_name,sur_name,average);
       }
       else if(average >= root.average)
       {
           root.right=insert_data(root.right,first_name,sur_name,average);
       }
       return root;
   }
  
   void print(double class_average)
   {
       print_function(root,class_average);
   }
  
   void print_function(Node root,double class_average)
   {
       if(root!=null)
       {
           print_function(root.left,class_average);
           if(root.average>=class_average)
           {
               System.out.println("\n");
               System.out.println(root.first_name+" "+root.sur_name+" "+root.average+" ");
              
           }
           print_function(root.right,class_average);
       }
   }
}

public class test
{
   public static void main(String[] args)
   {
   Scanner sc=new Scanner(System.in);  
      
       BST tree=new BST();
      
       int n=sc.nextInt();
      
       sc.nextLine();
      
       int count=n;
       double sum=0;
      
       while(n>0)
       {
          
           String s=sc.nextLine();
           String[] arr=s.split(" ");
          
           double quize=Double.parseDouble(arr[2]);
           double homework=Double.parseDouble(arr[3]);
           double project=Double.parseDouble(arr[4]);
           double midterm=Double.parseDouble(arr[5]);
           double final_exam=Double.parseDouble(arr[5]);
          
           double average=(double)((0.15*quize)+(0.15*homework)+(0.20*project)+(0.25*midterm)+(0.25*final_exam));
          
           tree.insert(arr[0],arr[1],average);
          
           sum=sum+average;
          
          
           System.out.println(" ");
           n--;
          
       }
      
       double class_average=(double)(sum/count);
      
       System.out.println("\n\nClass Average Mark : "+class_average);
       System.out.println("\n\nMarks which are greater tha or equal to "+class_average+" is below:");
      
       tree.print(class_average);
      
   }
}

Add a comment
Know the answer?
Add Answer to:
solve in java using Eclipse Question 6 Given a student information: Name, Surname, Quiz grade, Homework...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT