java pa17 dec _ Solutions
java pa17 dec _ Solutions
This site was designed with the .com website builder. Create your website today. Start Now
SOLUTIONS
0
Join Telegram Group Donation Here PAYTM
HOME Previous PA HOME Software Foundation Java Software Foundation -Python Donation OPA May - July Java PA Answer More
Question 1
In main method read an integer (containing only numeric digits without decimal and
special characters) and check whether the given number is perfect square or not. If it is
print TRUE (as string) else print FALSE(as string )
Solution:
import java.util.Scanner;
public class Solution4 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
double k = sc.nextInt();
k = Math.sqrt(k);
if((int)k == k)
System.out.println("TRUE");
else
System.out.println("FALSE");
}
}
Question 2
This site was designed with the .com website builder. Create your website today. Start Now
The method will return array of Associates where string parameter appears in technology
attribute(with case insensitive search) and experienceInyears should be multiple of 5.
Before calling this method (associateForgiventechnology) in the main method use scanner
object to read values for five associate objects referring the attributes in above sequence
then read value for search parameter.
Next call the method associateForgiventechnology,write the logic to print the ID's (in main
method) And display result.
Input
Alex
101
Java
15
Albert
102
Unix
20
Alferd
103
Testing
13
Alfa
104
Java
15
Almas
https://kumarweb28.wixsite.com/kumarweb/java-pa17-dec 2/5
2/19/25, 7:59 PM java pa17 dec | Solutions
Almas
This site was designed with the .com website builder. Create your website today. Start Now
105
Java
29
Java // Given technology
Output
101
104
Solution:
import java.util.ArrayList;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
// TODO Auto-generated method stub
int id ,exp;
String name,tech;
As[] ass = new As[5];
Scanner sc=new Scanner(System.in);
for(int i = 0;i<5;i++) {
System.out.println("id = ");
id = sc.nextInt();
System.out.println("name = ");
name = sc.next();
System.out.println("tech = ");
tech = sc.next();
System.out.println("exp = ");
exp = sc.nextInt();
ass[i] = new As(id, name, tech, exp);
}
String techa;
System.out.println("Enter tech = ");
techa = sc.next();
ArrayList<As> Os = getTech(ass,techa);
for(int i=0;i<Os.size();i++)
System.out.println(Os.get(i).getId()+" "+Os.get(i).getName()+"
"+Os.get(i).getTech()+" "+Os.get(i).getExp());
}
public static ArrayList<As> getTech(As[] d, String th) {
ArrayList<As> bs = new ArrayList<As>();
for(int i=0;i<d.length;i++) {
if(d[i].getTech().equals(th) && d[i].getExp()%5==0)
bs.add(d[i]);
}
return bs;
https://kumarweb28.wixsite.com/kumarweb/java-pa17-dec 3/5
2/19/25, 7:59 PM java pa17 dec | Solutions
return bs;
This site was designed with the .com website builder. Create your website today. Start Now
}
}
class As{
private int id;
private String name;
private String tech;
private int exp;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTech() {
return tech;
}
public void setTech(String tech) {
this.tech = tech;
}
public int getExp() {
return exp;
}
public void setExp(int exp) {
this.exp = exp;
}
public As(int id, String name, String tech, int exp) {
this.id = id;
this.name = name;
this.tech = tech;
this.exp = exp;
}
}
https://kumarweb28.wixsite.com/kumarweb/java-pa17-dec 4/5
2/19/25, 7:59 PM java pa17 dec | Solutions
This site was designed with the .com website builder. Create your website today. Start Now
https://kumarweb28.wixsite.com/kumarweb/java-pa17-dec 5/5