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
An important result of the development of anesthesia was?
Ksju [112]
It could be #2 since the patient would be asleep under the anesthesia they would be able to perform amputations more often since the patient would not be able to feel the pain during the procedure. It could also be #3 because if the patient is asleep you could use a more direct approach instead of avoiding certain procedures that would put the patient in a lot of pain if it was performed while they were awake. In all I would say the answer is #2, please comment which is the right answer, thank you.
7 0
4 years ago
What does UDP stand for?
sleet_krkn [62]
User Datagram Protocol
3 0
3 years ago
Read 2 more answers
I forgot hahahahahahahahahahahaha
Nadusha1986 [10]

Answer:

Condensation

Explanation:

Condensation is the conversion of a vapor or gas to a liquid.

4 0
3 years ago
Which option allows users to access the handout master to modify it?
leonid [27]

Answer:

b

Explanation:

im the goat

3 0
3 years ago
Read 2 more answers
In one paragraph summarize the history of the internet
ozzi

From 1982 to 1987 Bob Kahn and Vint Cerf are key members of a team which creates TCP/IP, the common language of all Internet computers. For the first time the it seemed as though the loose collection of networks which made up the ARPANET is seen as an “internet”, and the Internet as we know it today is born.

Explanation:

5 0
4 years ago
Other questions:
  • Where is the error in this code sequence?
    11·1 answer
  • World wide web is another name for Internet <br> True or false?
    8·2 answers
  • A _______________ is software that can guess passwords.
    5·1 answer
  • Which statement describes a disadvantage of e-government?
    9·1 answer
  • Is LTE faster than 4G?
    8·1 answer
  • Create a 4x5 matrix with ones everywhere and zeros on the last row.
    14·1 answer
  • Addition and subtraction are considered to be ____ operations performed by a computer.
    7·1 answer
  • Peter is software designer working at a big software company. He just found out that he has been shifted to their downtown branc
    10·1 answer
  • Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 te
    13·1 answer
  • How do you believe cryptocurrency work shape the next 10 years
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!