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
How are air masses and fronts the same. And how are they different. ​
Sergeu [11.5K]

Answer:

Air Masses are warmer air while front is an area of cold air that comes out warm. Font is a place where two of the air masses meet. Font is the borderline between an air mass.

Let me know if I was correct? Hope I could be of help!

Explanation:

7 0
3 years ago
Does a soda vending machine Give reciepts?<br><br>need for computer science hw
kupik [55]
No, they do not give receipts.<span />
6 0
3 years ago
Read 2 more answers
13. A 2-sided coin has an equal likelihood of landing on each side. One side is called "heads" and the other is called "tails".
serious [3.7K]

Answer: c

Explanation:

only reasonable answer

7 0
2 years ago
Which data type is 2.5?
Phoenix [80]

2.5 is a float.

Float stands for floating point. Floating point types are numbers with decimal places. I hope this helps!

6 0
2 years ago
Select the best answer from the drop-down menu. ________ networks use cables connected directly to the computer. Signals sent in
LekaFEV [45]

Answer: Wired, Wi-fi, Wi-fi, A wired network, Wi-fi

Explanation:

4 0
3 years ago
Other questions:
  • What type of installation should you perform if you want to install a 64-bit version of Windows on a computer that already has a
    8·1 answer
  • What is a main cause of a virus on a computer
    6·1 answer
  • What is the protocol in the web search at the bottom?
    13·1 answer
  • You receive $50 as a birthday gift and choose to spend it all on new wallpaper for your room. The opportunity cost of this decis
    7·1 answer
  • The graph of which function has an axis of symmetry at x=-1/4​
    15·1 answer
  • What method of the Math object can be used to return the largest value from the values that are passed to it?
    14·1 answer
  • Wired network are the most reliable and provide the highest speed?
    7·1 answer
  • Do pc players ever go outside?
    11·2 answers
  • Do you know the energy unit question?
    10·1 answer
  • When was the first analog device, the phonautograph, launched?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!