Showing posts with label Kyt. Show all posts
Showing posts with label Kyt. Show all posts

python code of 10 july



# Enter your code here. Read input from STDIN. Print output to STDOUT
class Student:
    def init(self,name,sub1,sub2,sub3):
        self.name=name
        self.sub1=sub1
        self.sub2=sub2
        self.sub3=sub3

    def calculateResult(self):
        average=0
        if(self.sub1>=40 and self.sub2>=40 and self.sub3>=40):
            average=(self.sub1+self.sub2+self.sub3)/3
        return average

class School:
    def init(self,name,studentDict):
        self.name=name
        self.studentDict=studentDict

    def getStudentResult(self):
        for i in self.studentDict.keys():
            avg=i.calculateResult()
            if(avg>60):
                self.studentDict[i]="pass"
        return self.studentDict

    def findStudentWithHighestMarks(self,lis):
        if len(lis)==0:
            return None
        else:
            dic2={}
            avg=0
            for i in lis:
                avg=i.calculateResult()
                dic2[i]=avg
            maximum=max(dic2,key=dic2.get)
            return maximum

if(name=="main"):
    n=int(input())
    dic={}
    lis1=[]
    for i in range(n):
        name=input()
        sub1=float(input())
        sub2=float(input())
        sub3=float(input())
        st=Student(name,sub1,sub2,sub3)
        dic[st]="fail"
    school_name=input()
    sc=School(school_name,dic)
    dic=sc.getStudentResult()
    for j in dic:
        if(dic[j]=="pass"):
            lis1.append(j)
    obj=sc.findStudentWithHighestMarks(lis1)
    for k in lis1:
        print (k.name)
    if(obj==None):
        print("No Student Passed")
    else:
        print(obj.name)

Algorithm


​1.Fastest Sorting alogithm ?
Ans:Merge
2.which is the not dynamic programming ?
Ans: Primes algorithm

​​3.Which algorithm will gives best performance 
when array is half or almost sorted ?
Ans:  Insertion sort
​​

4.To sort the records from large to small number 
and print the largest number ?
Ans: Option with Desc limit 1


5. Algorithm category.. ?
Ans : Minimum coupling and increase cohesion

html


1.All html tags have closing tags ?
Ans: false

2. which is the invalid field in HTML5 ?
Ans : Day

3. Which is invalid escape sequence in javascript ?

Ans : /e

4. a:link,a:visited {
background-color : red;
}
a:hover {
background-color : green
}
<a href = "abc.html">Click me </a>


Ans:will create a link having background color
 red and on moving the pointer background color
 will be green



5.what is command for order list with roman number ?
Ans: <ol type='I'>
​6.Which is not css unit ?
Ans: ut

7.<p>top news </p>
<blockquote url: hindu  news…. Com</blockquote>

Todays news block quote display or not ?


Ans : True


8.Which tag is used to emphasize the text.. ?
Ans : <emph> or <em>

9. p{
      color:green
     }
     <p>xyz</p>
     Paragraph is printed in which color

Ans :Green
10. Emphasing the text in html … ?

Ans : <em>

11. Tag which is not for formatting text ?

Ans : <p>

12.Syntax of background image in css ?
Ans: background-image

unix

 Unix Code of 19 june              
Student detail
 UNIX CODING ANSWER 12 June

Unix coding answer 26 june

java program

                                         JAVA CODE 
 

JAVA Proctored Assessment on 17th  Dec                        



 

JAVA Proctored Assessment on 28th  Dec 


 


JAVA Proctored Assessment on 15th  Jan 


 


JAVA Proctored Assessment on 25th  Jan 



 

JAVA Proctored Assessment on 10th  Feb 



 

JAVA Proctored Assessment on 13th  Feb 



 

JAVA Proctored Assessment on 2nd march




        java proctored assessment on 19 june



Java Proctored Assessment Programming solution 13th February


Java Proctored Assessment Programming solution 13th  February



Question 1.

Write a Program to print smallest vowel in the given line…(Ascii Values)

input:
matrix

output:
a

Solution:


import java.lang.*;
import java.util.*;
import java.io.*;
import java.math.*;

public class Main
{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        s=s.toLowerCase();
        int n=s.length();
        int c=0;
        char[] ch=s.toCharArray();
        for(int i=0;i<n;i++)
        {
            if(s.charAt(i)=='a' || s.charAt(i)=='e' || s.charAt(i)=='i' || s.charAt(i)=='o' || s.charAt(i)=='u')
            {
                c++;
            }
        }
        char[] c1=new char[c];
        int k=0;
        for(int i=0;i<n;i++)
        {
            if(s.charAt(i)=='a' || s.charAt(i)=='e' || s.charAt(i)=='i' || s.charAt(i)=='o' || s.charAt(i)=='u')
            {
                c1[k++]=ch[i];
            }
        }
        Arrays.sort(c1);
        System.out.println(c1[0]);
       
    }
}

Question 2.


Create a Sim Class with following Attributes
int simId;
String customerName;
double balance;
double ratePerSecond;
String circle;


create a public Class Solution in which take input of 5 object and then take 2 input (circle1, circle2) for circle of matches as circle1 and choose only those objects which are match with circle1.

Create a method named as transferCircle() and passed sim object and circle1, circle2 as parameter and arrange sim object in descending order as per ratePerSecond


Print the output as simId, customerName, circle, ratePerSecond.

Input:


1
raju
130
1.32
mum
2
sachin
120
2.26
ahd
3
ram
200
2.54
kol
4
shubham
640
3.21
ahd
5
kalpesh
150
1.8
ahd
ahd
kol


Output:


4 shubham kol 3.21
2 sachin kol 2.26
5 kalpesh kol 1.8

Solution:


import java.util.Scanner;
public class SimSolution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Sim1[] sim = new Sim1[5];
for (int i = 0; i < sim.length; i++) {
int simId = sc.nextInt();
sc.nextLine();
String name = sc.nextLine();
double balance = sc.nextDouble();
double ratePersecond = sc.nextDouble();
sc.nextLine();
String circle = sc.nextLine();
sim[i] = new Sim1(simId, name, balance,
ratePersecond, circle);
}
String circle1 = sc.nextLine();
String circle2 = sc.nextLine();
Sim1[] result = transferCircle(sim, circle1, circle2);
for (int i = 0; i < result.length; i++) {
System.out.println(result[i].getSimId() + " " +
result[i].getName() + " " + result[i].getCircle() + " "
+ result[i].getRatePersecond());
}
sc.close();
}
public static Sim1[] transferCircle(Sim1[] sim, String
circle1, String circle2) {
Sim1[] temp;
int j = 0;
for (int i = 0; i < sim.length; i++) {
if (sim[i].getCircle().equals(circle1)) {
j++;
}
}
temp = new Sim1[j];
j = 0;
for (int i = 0; i < sim.length; i++) {
if (sim[i].getCircle().equals(circle1)) {
temp[j] = sim[i];
temp[j++].setCircle(circle2);
}
}
for (int i = 0; i < j - 1; i++) {
for (int k = 0; k < j - 1; k++) {
if (temp[k].getRatePersecond() < temp[k +
1].getRatePersecond()) {
Sim1 a = temp[k];
temp[k] = temp[k + 1];
temp[k + 1] = a;
}
}
}
return temp;
}
}
class Sim1 {
private int simId;
private String name;
private double balance;
private double ratePersecond;
private String circle;
public Sim1(int simId, String name, double balance, double
ratePersecond, String circle) {
this.simId = simId;
this.name = name;
this.balance = balance;
this.ratePersecond = ratePersecond;
this.circle = circle;
}
public int getSimId() {
return simId;
}
public void setSimId(int simId) {
this.simId = simId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getRatePersecond() {
return ratePersecond;
}
public void setRatePersecond(double ratePersecond) {
this.ratePersecond = ratePersecond;
}
public String getCircle() {
return circle;
}
public void setCircle(String circle) {
this.circle = circle;
}
}

OPA -JAVA UNIX Student details

OPA -JAVA UNIX Student details


#!/bin/bash
read 
awk 'BEGIN{FS=",";t=0}
 {
a[t]=$1;
b[t]=$3+$4;
c[t]=$2;
 
t=t+1
 
}
END
{
for(i=0;i<t;++i)
{
   ma=0;
    pos=i;
    for(j=0;j<t;++j)
    {
        if (b[j]>ma)
        {
            ma=b[j];
            pos=j;
        }
    }
    if (b[pos]>99)
    print a[pos],c[pos];
    b[pos]=-1;
 
}
}
'

Java Movie Management

Java Movie Management








import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
   public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Movie[] mv = new Movie[4];
        for(int i=0;i<4;i++)
        {
            int a = sc.nextInt();sc.nextLine();
            String b = sc.nextLine();
            int c = sc.nextInt();
            int d = sc.nextInt();
            mv[i] = new Movie(a,b,c,d);
        }
        sc.nextLine();
        String nm = sc.nextLine();
        int um = sc.nextInt();
        int dm = sc.nextInt();
        int res = findAvgBudgetByDirector(mv, nm);
        if (res>0)
        System.out.println(res);
        else
        System.out.println("Sorry - The given director has not yet directed any movie");
        Movie temp = getMovieByRatingBudget(mv, um, dm);
        if(temp == null)
        System.out.println("Sorry - No movie is available with the specified rating and budget requirement");
        else
        System.out.println(temp.id);

    }

    public static int findAvgBudgetByDirector (Movie[] mv, String nm)
      {
          //method logic
          int avg,s=0,j=0;
          for(int i=0;i<4;i++)
          {              
              if(nm.equalsIgnoreCase(mv[i].dt))
              {
                  s = s+mv[i].bt;
                  j++;
              }
          }
              if(j>0)
              {
                  avg = s/j;
                  return avg;
              }          
              else 
              return 0;
      }

    public static Movie getMovieByRatingBudget(Movie[] mv, int rating, int budget)
      {
          //method logic
          Movie temp = new Movie();
          for(int i=0;i<4;i++)
          {
              if((rating == mv[i].rt) && (budget == mv[i].bt) && (mv[i].bt % mv[i].rt == 0))
              {
                  temp.id = mv[i].id;
                  return temp;
              }
          }
          return null;   
          
      }
}

class Movie
{
    //code to build Movie class
    int id,rt,bt;
    String dt;
    Movie()
    {

    }
    Movie(int id, String dt, int rt, int bt)
    {
        this.id = id;
        this.dt = dt;
        this.rt = rt;
        this.bt = bt;
    }
}

Java Proctored Assessment Programming solution 2nd march ​

Java Proctored Assessment Programming solution 2nd  march


Question 1.

    Reverse the given number
INPUT

12345

OUTPUT

Reverse of the number is 54321
Solution:

import java.util.Scanner;
public class Solution1000 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuffer sb = new
StringBuffer(sc.nextLine());
System.out.println("Reverse of the number is
"+sb.reverse());
}
}
Question 2.
Sort the medicines according to Medicine prices with
Respective to the disease
INPUT :

dolo650
batch1
fever
100
dolo990
batch2
headache
101
paracetemol
batch3
bodypains
102
almox500
batch4
fever
103
fever

OUTPUT :

100
103
Solution:

import java.util.Arrays;
import java.util.Scanner;
public class Solution100 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Medicine[] m = new Medicine[4];
for(int i =0;i<m.length;i++) {
String a = sc.nextLine();
 String b = sc.nextLine();
 String c = sc.nextLine();
 int d = sc.nextInt();
 sc.nextLine();
 m[i] = new Medicine(a,b,c,d);

}
String e = sc.nextLine();
 Integer[] f = sortAccordingtoPrices(m,e);
 for(Integer g : f) {
 System.out.println(g);
 }
}
public static Integer[] sortAccordingtoPrices(Medicine[] m,
String e) {
int count =0 ;
for(int i=0;i<m.length;i++) {
if(m[i].getDisease().equals(e)) {
count++;
}
}
Integer[] j = new Integer[count];
int k = 0;
for(int i=0;i<m.length;i++) {
if(m[i].getDisease().equalsIsIgnorecase(e)) {
j[k++] = m[i].getPrice();
Arrays.sort(j);
}
}
return j;
}
}
class Medicine{
private String MedicineName;
private String batch;
private String disease;
private int price;
public String getMedicineName() {
return MedicineName;
}
public void setMedicineName(String medicineName) {
MedicineName = medicineName;
}
public String getBatch() {
return batch;
}
public void setBatch(String batch) {
this.batch = batch;
}
public String getDisease() {
return disease;
}
public void setDisease(String disease) {
this.disease = disease;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public Medicine(String medicineName, String batch, String
disease, int price) {
this.MedicineName = medicineName;
this.batch = batch;
this.disease = disease;
this.price = price;
}
}