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
vodomira [7]
3 years ago
13

Write a function in Java to implement the following logic:

Computers and Technology
1 answer:
galben [10]3 years ago
8 0

Answer:

Explanation:

The following Java code basically divides the goal size by 5 and rounds the answer to the lowest whole number. Then multiplies that answer by 5 and goes adding 1 until the exact goal size is met. If the value is passed then that means that using the current brick sizes it is not possible to make the goal. Otherwise, it will print out that it is possible.

import java.io.*;

import java.util.Scanner;

public class Main{

       public static void main(String args[]) throws IOException {

               String answer = "No, it is not possible";

               Scanner in = new Scanner(System.in);

               System.out.println("Enter goal size: ");

               float goalSize = in.nextFloat();

               float currentSize = (float) Math.floor(goalSize / 5);

               currentSize = currentSize * 5;

               while (true) {

                       if (currentSize < goalSize) {

                               currentSize += 1;

                       } else if(currentSize == goalSize) {

                               answer = "Yes, it is possible";

                               break;

                       } else {

                               break;

                       }

               }

               System.out.println(answer);

       }

You might be interested in
Why do attackers tend to target public or private Wi-fi networks?
Anika [276]

Answer:

The answer to this question is given below in this explanation section.

Explanation:

A free WiFi connection in a public space can seem like a lifesaver when you are on the go.But if you decide to use public WiFi just be aware that you could be making yourself an easy target for hackers and putting your information and more at risk.

one of the dangers of using a public WiFi network is that data over this type of open  connection is often encrypted and  unsecured ,leaving you vulnerable to a man in the middle attack.It when a cyber criminal exploits a security  flaw in the network to intercept data

  • Avoid connecting to public WiFi connection. i if you must use a public WiFi hotpots also use a virtual privater network to secure your connection.
  • Do not  log in to password protected websites that contains sensitive information when using a public WiFi connection for example banking and social networking sites or even email.
  • Keep your software patched and up to date and all your devices even your mobiles ones to avoid any potential infection by viruses or malware if you do use unsecured public WiFi.

5 0
3 years ago
Are you concerned that strangers may have access to the personal information you share on social media platforms? Why or why not
GuDViN [60]
It makes me a little uneasy at times, yes, but I know that they cannot find me unless I share way too much.
Hope this helps~!
~{Oh Mrs. Believer}
4 0
3 years ago
When you were configuring Encrypting File System (EFS) in the lab, a __________ on the Documents folder in the File Explorer ind
harina [27]
I’m not 100% sure but I think it’s a padlock that represents it
3 0
3 years ago
2. Sometimes, validating the HTML code for a web page will help you debug an application, because a. the page won’t run in a bro
aleksandrvk [35]

Answer:

Option c. you can be sure that a validated page will work correctly in a browser

Explanation:

A faulty HTML codes can result in various types of unexpected error when running the web page in different platforms or browsers. This will cause an inconsistent style or layout. HTML code validation can check if the code adopt the standard tag and structure. A validated HTML code can guarantee a web application running smoothly in different browsers and always present consistent web page layout to users. HTML code validation has become part of the standard workflow before a web page go live in internet.

4 0
3 years ago
Point: A Point in a two dimensional plane has an integer x coordinate value and an integer y coordinate value.
UNO [17]

Answer:

They are connected

Explanation:

8 0
3 years ago
Other questions:
  • Monetary Policy can be either Expansionary or Contractionary. Which of the following actions classify as Expansionary Monetary P
    7·2 answers
  • Insert a function in cell g5 to calculate the first student's monthly payment, using appropriate relative and absolute cell refe
    13·1 answer
  • I have a question on an IT crossword the question is as follows
    12·1 answer
  • Software as a Service (SaaS) refers to the use of computing resources, including software and data storage, on the Internet rath
    13·1 answer
  • What important feature of an email gives you a clue about what the sender wants to tell you?
    12·2 answers
  • One of the most common encryption protocols in use today. It is an asymmetric protocol that enables the sharing of a secret key
    7·1 answer
  • What allows you to heal<br><br><br><br> undesirable portions of an image​
    9·1 answer
  • 4.2 Lesson Practice​
    8·2 answers
  • The function's only behavior should be to return the sum of array userVals' elements. What common error does the function make?
    6·1 answer
  • How to install an older version of prettier on yarn
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!