Mini project core java hands on solution | Mini-project - Core Java | Fresco Play Hands on Solution | Course ID: 63716



The main agenda of this solution is those who are unable to do this course due to facing some issues, a little bit of lack of knowledge on these hands-on questions. Try to understand these codes and solve your hands-On Problems. (Not encourage copy and paste these solutions).

The Course Id: -  63716


1. Strings in Java




import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Solutions{
   
    public static int charSearch(String str, char ch) {
        // Count the frequency of character ch in str
        HashMap<Character, Integer> chrs = new HashMap<>();
        for (int i = 0; i < str.length(); i++) {
            chrs.put(str.charAt(i), chrs.getOrDefault(str.charAt(i), 0) + 1);
        }
        return chrs.getOrDefault(ch, 0);
    }

    public static void main(String[] args) throws IOException {
        System.out.println(charSearch("Hello", 'o'));  // ✅ Fixed: 'o' is a char
    }
}




2. Arrays in Java




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

public class Solutions {
    public static void main(String args[] ) throws Exception {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */
        int[] arr=new int[10];
        for(int i=0;i<10;i++)
        arr[i]=0;
        Scanner sc=new Scanner(System.in);
        String text=sc.next();
        for(int i=0;i<text.length();i++)
        {
            arr[Integer.parseInt(text.substring(i,i+1))]++;
        }
        for(int i=0;i<10;i++)
        {
            if(arr[i]!=0)
            System.out.println(i+": "+arr[i]);
        }
    }
}



3. Collections in Java:- 



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

public class Solutions{
    public static void main(String args[] ) throws Exception {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT */
        HashMap<Integer, String> ppl = new HashMap<Integer, String>();
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        while(n-->0)
        {
            // System.out.println(sc.nextInt());
            int num=sc.nextInt();
            String val=sc.nextLine();
            // System.out.println(val);
            val=val.trim();
            ppl.put(num,val);
        }
        int num=sc.nextInt();
        if(ppl.containsKey(num))
            System.out.println(ppl.get(num));
        else
            System.out.println(-1);
       
       
    }
}



----Thank you----


Post a Comment

0 Comments