Skip to main content

Posts

Showing posts from September, 2022

Mock PRA java solution .

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[] ) throws Exception { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ Scanner sc = new Scanner (System. in ) ; int n = sc.nextInt() ; Vehicle[] vl = new Vehicle[n] ; for ( int i= 0 ; i<n ; i++){ int number = sc.nextInt() ; sc.nextLine() ; String name = sc.nextLine() ; double price = sc.nextDouble() ; sc.nextLine() ; vl[i] = new Vehicle(number , name , price) ; } String name = sc.nextLine() ; Vehicle ans1 = findVehicleWithMinimumPrice (vl) ; if (ans1== null ) { System. out .println( "No Vehicle found with mentioned attribute." ) ; } else { System. out .println( "number-" +ans1.getNumber()) ;