top of page
Home: Blog2
Writer's pictureAnuj Yadav

Java Hackathon Coding Solution -17/04/2020

There was only one question. The timing was 60 minutes.







import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        //code to read values 
        //code to call required method
        //code to display the resultstem.in
        Scanner sc=new Scanner(System.in);
        Institution o1=new Institution();
        Institution o2=new Institution();
        Institution o3=new Institution();
        Institution o4=new Institution();
        Institution o[]={o1,o2,o3,o4};
        for (int i=0;i<o.length;i++)
        {
            o[i].id=sc.nextInt();
            sc.nextLine();
            o[i].name=sc.next();
            o[i].sp=sc.next();
            o[i].sc=sc.nextInt();
            sc.nextLine();
            o[i].l=sc.next();
        }
        //  for (int i=0;i<o.length;i++)
        //  {
        //      System.out.println(o[i].id);
        //       System.out.println(o[i].name);
        //        System.out.println(o[i].sp);
        //        System.out.println(o[i].sc);
        //         System.out.println(o[i].l);
               
               
        //  }
        sc.nextLine();
        String l=sc.nextLine();
        String n=sc.nextLine().toLowerCase();
       //System.out.println("l "+l+" "+"n "+n);
        int s=0;
        for(int i=0;i<o.length;i++)
        {
            if(o[i].l.equals(l))
            {
                s=s+o[i].sc;
            }
           // System.out.println(o[i].l);
        }
        if(s>0)
        {
            System.out.println(s);
        }
        else
        {
            System.out.println("There are no cleared students in this particular location");
        }
        int c=0;
        for(int i=0;i<o.length;i++)
        {
            String k=o[i].name.toLowerCase();
            if (k.equals(n))
            {
                c+=1;
                int grade=0;
                int sp1=Integer.parseInt(o[i].sp);
                grade=(sp1*100)/o[i].sc;
                if (grade>=80)
                {
                    System.out.println(o[i].name+"::"+"A");
                }
                else
                {
                    System.out.println(o[i].name+"::"+"B");
                }

            }
            

            

        }
        if(c==0)
        {
        
                System.out.println("No Institute is available with the specified name");
        
        }


    }
    
     
  }

class Institution 
{
   int id;
   String name;
   String sp;
   int sc;
   String l;
   String grade;
}

100 views0 comments

Recent Posts

See All

Comentarios


Home: Subscribe

CONTACT

 Kanpur, India

8299229032

  • twitter

Thanks for submitting!

Home: Contact
bottom of page