Answer:C.apple Osx
Answer C
Output device - keyboard
Input device- mouse
Answer:
- public class Square {
- public static boolean isPerfectSquare(int n){
- int sqrt_n = (int) Math.sqrt(n);
- if(sqrt_n * sqrt_n == n ){
- return true;
- }else{
- return false;
- }
- }
- }
Explanation:
Firstly, use sqrt method from Math package to calculate the square root of input n (Line 3). Cast the result to integer and assign it to sqrt_n variable.
Next, square the sqrt_n and check if it is equal to input n (Line 4). If so, return true, if not, return false (Line 4-8).
Answer:
In Java:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n;
System.out.print("Max of series: ");
n = input.nextInt();
for(int i = 1; i<=n;i+=4){
System.out.print(i+" ");
}
}
}
Explanation:
This declares n as integer. n represents the maximum of the series
int n;
This prompts the user for maximum of the series
System.out.print("Max of series: ");
This gets user input for n
n = input.nextInt();
The following iteration prints from 1 to n, with an increment of 4
<em> for(int i = 1; i<=n;i+=4){</em>
<em> System.out.print(i+" ");</em>
<em>}</em>
The answer is c
But I’m not sure