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
Given the function definition below, what is the effect of thecall:
Romashka-Z-Leto [24]

Answer:

Hi!

The correct answer is E.

Explanation:

void change(int ar[], int low, inthigh)  {  

 int temp;

 if(low< high)  {  <em>// here ask if the positions low and high of the array are the same.</em>

  temp= ar[low];  <em>// first, saves the element on ar[low] in temp.</em>

  ar[low]= ar[high];  <em>// second, the element on ar[high] in ar[low]. First switch.</em>

  ar[high]= temp;  <em>// third, saves the element on temp in ar[high]. Complete switch.</em>

  change(ar,low + 1, high - 1);  <em>// Recursive call, adding one position to low, and subtracting one position to high. </em><em>Important: </em><em>When low and high have the same value, the recursive call will finish.</em>

}

}

Result: Switch the lower half of elements in the array with the upper half.

8 0
3 years ago
Read 2 more answers
To save the changes to the layout of a table, click the Save button on the _____.
kari74 [83]
Quick access toolbar :)))))))))
7 0
3 years ago
A field with the extend data type can contain an attached file, such as an image, document, chart, or spreadsheet.
enyata [817]
The attachment data type can contain an attached file such as image document chart or spreadsheet. hope I helped
8 0
3 years ago
How do you answer questions
Vera_Pavlovna [14]

Answer:

like this

Explanation:

<h3>you click answer and then<u><em> boom</em></u></h3>
7 0
3 years ago
I need help!! I decided to go back to college this year and am taking Intro to Logic and Programming. I have an assignment due t
Artist 52 [7]

Answer:

Monday Video: 5.4.20 Section 18.5

Work due: 18.5 Worksheet

CW

Tuesday Video: 5.5.20 Section 18.6

Work due: 18.6 Worksheet

HW

Wednesday Video: 5.6.20 Section 18.7

Work due: 18.7 Classwork

CW

Thursday Video: 5.7.20 Section 18.7

Work due: 18.7 Homework

HW

Friday Video: 5.8.20 Section 18.5-18.7

Work due: Textbook page 615 #5-19 (not #13)

HWaccuracy

Explanation:

7 0
3 years ago
Other questions:
  • The most common solution to supply chain uncertainties is to build inventories or __________ as insurance.
    6·1 answer
  • What should be included as part of the approval process? in relation to computer forensics
    14·1 answer
  • Yahoo and Google are examples of __________ used to perform Internet research.
    14·2 answers
  • what is a massive online storage that allows for Access by any internet-connected device running web browser. use for Less priva
    6·1 answer
  • If you see ________________________ in a cell, it means the column is not wide enough to display the cell content. Select one: a
    15·1 answer
  • What function returns a line and moves the file pointer to the next line?
    9·1 answer
  • Write a qbasic program to display integer numbers 1 to 100 using the for next loop<br>​
    9·1 answer
  • the increase and decrease font button and the change text colour button (as shown in the picture )are include in which group ?​
    6·1 answer
  • How many 60 KB jpeg files can be stored on a 2 MB folder in your hard drive?​
    7·1 answer
  • The terminology used to describe a possible path to resolution to a problem from one end to the other is called what?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!