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
Create a database with information about products in a catalog. As you plan, keep in mind that later you will want to sort this
nika2105 [10]

pro.no. Qty  Price  Description

1            23   1.00     Apple

2           90   1.00     Banana

3           16    1.00     Orange

4           124  1.00     Pear

5           98   1.00     Blue Berry

6           25   1.00     Raspberry

7           76   1.00     Black Berry

8           00   1.00     Pineapple

9           231  1.00     Green Grape

10          689 1.00     Red Grape

11           2      1.00     Watermellon

3 0
3 years ago
Read 2 more answers
What are the elements of an autobiographical narrative similar to those of a short story?
sattari [20]
A. because the form is about stories from events in a writer's life
6 0
3 years ago
Network is a process by which several protocols evolve to form a single product.
astraxan [27]

Answer:

Is this like a true or false thing or just a statement?

6 0
3 years ago
Getting access to web browsing software to install it on a computer or to update your existing software is called _________ .
Ivenika [448]

Answer:

Downloading and/or Burning it on to your computer

Hope this helped! if so please mark it as brainliest

Explanation:

8 0
3 years ago
Read 2 more answers
Linda is the owner of Souvenirstop, a chain of souvenir shops. One of the shops is located at the City Centre Mall. Though the s
Klio2033 [76]

Answer:

attraction and attention

6 0
3 years ago
Other questions:
  • Write a program that asks the user to enter two dates (in YYYY-MM-DD format), and then prints which date is earlier. Your progra
    15·1 answer
  • Your car must have two red stoplights, seen from ______ feet in the daytime, that must come on when the foot brake is pressed.
    6·1 answer
  • What is the purpose of an arraignment?
    9·2 answers
  • list the six external parts or "peripherals" of a computer system and identify which are output and which are input devices.
    15·1 answer
  • Write a program that determines the value of the coins in a jar and prints the total in dollars and cents. Read integer values t
    5·1 answer
  • In a registration database, Ross has tables for student, professor, classroom, class, class-hour. Since his campus has about 12,
    9·1 answer
  • If tech is smarter than us. How did a human make something smarter than him/her?
    9·2 answers
  • What is the plan to make optimum usage of available spaces?
    15·1 answer
  • The chain of _____ documents that the evidence was under strict control at all times and no unauthorized person was given the op
    13·1 answer
  • 30 POINTS PLS HELLLLPPP WILL GIVE BRAINLIEST What behavior do elements in a stack follow? first in, last out, or FILO behavior l
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!