Kytcs.Blogspot.com: OPA
Showing posts with label OPA. Show all posts
Showing posts with label OPA. Show all posts

PYthon OPA 12 may

 class ParkedVehicle:

    def __init__(self,vs,fw,pf,vp):
        self.vehicleSeq=vs
        self.fourWheeler=fw
        self.parkedFor=pf
        self.valetParking=vp
        self.parkedStatus="Parked"

class ParkingLot:
 
    def __init__(self,pv):
        self.parkedVehicle=pv
 
    def updateParkedStatus(self,lot_no):
 
        obj=self.parkedVehicle.get(lot_no,None)
        if obj==None:
            return None
        else :
            obj.parkedStatus="Cleared"
            return lot_no
 
 
 
    def getParkingCharges(self,lot_no):
        parkingCharges=0
 
        obj=self.parkedVehicle.get(lot_no,None)
 
        if obj==None:
            return None
        else:
            if obj.fourWheeler=="Yes":
                parkingCharges+=obj.parkedFor*50
            else:
                parkingCharges+=obj.parkedFor*30
 
            if obj.valetParking=="Yes":
                parkingCharges+=10
 
            return parkingCharges
 
 
 
 
N=int(input())
 
qewdkl={}
for dog in range(N):
 
    vs=int(input())
    fw=input()
    parkedfor=float(input())
    vp=input()
    lotno=int(input())
 
    q[lotno]=ParkedVehicle(vs,fw,parkedfor,vp)
 
asd=ParkingLot(q)
 
lot=int(input())
 
 
tef=asd.updateParkedStatus(lot)
 
asd=asd.getParkingCharges(lot)
 
if tef==None:
    print ("Lot Number Invalid")
else:
    print(tef,"Cleared")
 
if asd==None:
    print("Lot Number Invalid")
else:
    print(asd)

DOTNET

Welcome to the my blog




            Course        
             
                HTML-5  
 
         
                  CSS

              javascript  

                 OpsRio


javascript


Welcome to the my blog






































Java Movie Management

Welcome to the my blog



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;
    }
}

Unix code

Welcome to the my blog
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 Proctored Assessment

java pa 13 feb


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;
}
}

Followers

Ad Space