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
You are troubleshooting a computer that is in the design phase. The problem you see is that the CPU is not receiving information
IgorC [24]

Answer:

The correct option of the following question is c). control bus.

Explanation:

A control bus is a bus of the computer system which is use by the CPU(Central Processing Unit) to communicate with the devices which are contained with the computer.

CPU transmits the variety of the control signals to devices and components to transmits the control signal to the CPU by using control bus. One of the main objective of the bus is to minimize lines which are needed for the communication.

3 0
3 years ago
When you receive five job offers what does it mean
7nadin3 [17]

that you are a great canidate, in high demand, and well trained!

6 0
3 years ago
How can netiquette help you communicate when texting or instant messaging?
Yanka [14]

1. D

2. C

it allows citizens to submit anonymous tips to the police

5 0
3 years ago
Choose the 3 Points in good story telling
Sidana [21]

Answer:

1.Choose a clear central message 2. Embrace conflict 3.Have a clear structure  

Explanation:

8 0
2 years ago
Carla needs to list the role for each consultant. Those with four or more years of 26 15 experience take the Lead role. Otherwis
saveliy_v [14]

Answer :

The output is attached below

Explanation:

The following formula needs to be entered into cell N5:

=IF($M5>=4,"Lead","Associate")

4 0
3 years ago
Other questions:
  • Common icons found on the Windows desktop are _____.
    6·2 answers
  • Assume you had a .csv file with data already populated that you wanted to use for a mail merge. Which button would you press to
    8·1 answer
  • Which layer concerns the gateway to the network?
    10·1 answer
  • Enumeration is defined as the process of extracting user names, machine names, network resources, shares, and services from a sy
    13·1 answer
  • Why do we allow electronic instruments to warm-up before use?
    11·1 answer
  • One lap around a standard high-school running track is exactly 0.25 miles. Write the function miles_to_laps() that takes a numbe
    8·1 answer
  • PLEASE HELP
    7·2 answers
  • A mysql prompt has been opened for you. Using the college database, complete the following tasks (use either a single-line or a
    7·1 answer
  • Elena wrote the following code in Scratch to have the sprite move and then turn around. However, the code does not work as expec
    5·1 answer
  • What is a Type 10 SD card?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!