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 can videos be streamed from the cloud to a computer with no loss in
mezya [45]
I think the answer is B
3 0
3 years ago
Read 2 more answers
How does the speaker feel about traditional forms of poetry
Salsk061 [2.6K]
A speaker sometimes is not able to capture the intended details since it is affected by homophones.
7 0
3 years ago
Read 2 more answers
Have fire have ....<br><br>babi​ from babi098
Genrish500 [490]

Answer:

yessss I tooo have a fire at my home

lolololololololololo

ok have a great day what is your name ?

4 0
3 years ago
Which of the following are examples of software? (Select all that apply)
olchik [2.2K]
Put a photo or something
8 0
2 years ago
Read 2 more answers
What is the difference between the paste and paste special options
Darina [25.2K]

Paste special allows the item being transferred to be formatted in several different ways. Paste is just going to be transferred the exact way you copied it.

7 0
3 years ago
Other questions:
  • What is the purpose of a scatter plot introduction to computer applications
    6·2 answers
  • Clep allows students to do all of thw following except which?
    11·2 answers
  • Which is the last step in conducting a URL search?
    5·2 answers
  • An interpreter _______. converts the procedural language one statement at a time converts the source code into machine language
    12·1 answer
  • Select the correct answer.
    6·2 answers
  • What does NCR stand for
    12·2 answers
  • Write a function named change() that has an integer parameter and six integers reference parameters named hundreds, fifties, twe
    7·1 answer
  • Here's a better picture of my pc mouse and keyboard​
    5·2 answers
  • What do you suggest for Father's Day?​
    7·1 answer
  • Look at the code in the example below, and then answer the question.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!