1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mihalych1998 [28]
3 years ago
15

Complete the method, isPerfectSquare(). The method takes in a positive integer, n. It returns a boolean that is true if n is a p

erfect square, false otherwise. A perfect square is an integer whose square root is also an integer. You may assume that n is a positive integer.
Hint: find the square root of n, cast it to an int value, then square it and compare this square to n.
Starter code:-
public class Square {
public static boolean isPerfectSquare(int n) {
//TODO: complete this method
}
}
Computers and Technology
1 answer:
ratelena [41]3 years ago
7 0

Answer:

  1. public class Square {
  2.    public static boolean isPerfectSquare(int n){
  3.        int sqrt_n = (int) Math.sqrt(n);
  4.        if(sqrt_n * sqrt_n == n ){
  5.            return true;
  6.        }else{
  7.            return false;
  8.        }
  9.    }
  10. }

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).

You might be interested in
Scott does not use privacy settings on his social media account. He includes all his contact details on his profile and posts lo
tia_tia [17]

Answer:

A. B. D.

Explanation:

Idrk just sayin

6 0
3 years ago
Read 2 more answers
Write a C# program that prints the number of quarters, dimes, nickels, and pennies that a customer should get back as change. De
kondor19780726 [428]

Following are the code of C# to prints the number of quarters, dimes, nickels, and pennies

Program Explanation:

  • Declaration of the namespace.
  • Made a class named "Class1".
  • Declared the methods as well as the attributes.
  • Declared the main method.
  • Wrote the statements according to the given query.

Program:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace Project1

{

   class Class1      

   {

       static void Main(string[] args)

       {

           int change = 0;

           int quart, dim, nic, pen;

           Console.WriteLine("enter amount of cents (less than 99)");

           change = int.Parse(Console.ReadLine());

           quart = change / 25; //calculate the remainder              

           int p = change % 25;

           dim = (p / 10);

           int a = p % 10;

           // Nickles

           nic = a / 5;

           int c = a % 5;

           pen = c;

           Console.Write("There are {0} quarters.\n", quart);

           Console.Write("There are {0} dimes.\n", dim);

           Console.Write("There are {0} nickels.\n", nic);

           Console.Write("There are {0} pennies.\n", pen);

           Console.ReadLine();

       }

   }

}

Output:

Please find the attachment of the output.

Learn more about C# here:

brainly.com/question/5023004

6 0
3 years ago
True/False: Software engineering is a field that encompasses designing, writing, testing, debugging, documenting, modifying, and
Natali [406]

Answer:

The answer is "True".

Explanation:

The software engineering is the mechanism by which end-user programs are evaluated and planned, to built and reviewed, and fulfill these needs by using language software programming.

  • The fundamental goal of software engineering is to design software, that uses the techniques and processes, that are applied to make large systems and frequently used to produce quality applications.
  • It is also used in modifying and maintaining software.

7 0
3 years ago
In an agile process, story points are an absolute measurement, which differs from function points, as function points are relati
aleksandrvk [35]

Answer: True

Explanation: In an agile project, the story point are for the determination of the level of difficulty in the implementation of the story. They are accurate and also helps in the further improvement.They also help to reduce the time of plan because of being precise.

Function points work in accordance with the function and depends upon the relative measurements and functional size measurement which makes them less precise.Thus, the given statement is true.

6 0
3 years ago
Which osi layer is responsible for directing data from one lan to another?
likoan [24]
The Network layer (1) directs date from one LAN to another.
5 0
4 years ago
Other questions:
  • Which is a network of devices built around a person, typically within 10 meters of range?
    5·1 answer
  • What does ACCU stand for?
    13·2 answers
  • How does heat affect quantum computers ?
    10·1 answer
  • COMPUTER FUNDIMENTAL HELP 15 POINTS!! RESEND IT
    7·2 answers
  • Which of the following is the shortcut key combination for pasting copied text?
    11·2 answers
  • Useful open source applications include the popular Web browser Mozilla Firefox, the e-mail application Thunderbird, the relatio
    7·2 answers
  • How do you think someone has programmed computer calculator?​
    13·1 answer
  • How many sections of a job description are there
    5·1 answer
  • What type of media is a hard disk​
    9·1 answer
  • Suppose you are developing a cricket game in which you are asked to enter score of every ball and can score maximum 6 on each ba
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!