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 do you properly turn off a computer?
Ugo [173]

Answer:

with the power button or do the sleep or shut down

and by the type of computer

Explanation:

sry if its wrong

have a good day:)

-XxMissNobodyxX

7 0
2 years ago
Read 2 more answers
Does someone know what type of usb is that one called?
Doss [256]
It is USB 2.0 mini b 5 pin

3 0
3 years ago
Read 2 more answers
Hexadecimal (19BACDFE)H into Octal. Please write step by step.
lubasha [3.4K]
The H idk, but till E is i think 3156546776
4 0
4 years ago
Suppose within your Web browser you click on a link to obtain a Web page. The IP address for the associated URL is not cached in
Firdavs [7]

Answer:

RTT1+ RTT2+..... RTTn

Explanation:

The total estimated time to get the IP address is

RTT1+ RTT2+..... RTTn

Once the IP address is known, O RTT elapses to set up the TCP connection and another O RTT elapses to request and receive the small object. The total response time is

2RTT0+RTT1+RTT2+.....RTTn

7 0
3 years ago
Write a program with a loop that asks the user to enter a series of positive numbers. the user should enter a negative number to
Dafna11 [192]
Int main(void){
int  n,s=0;
while(1){
scanf(" %d",&n);
if(n<0) break;
s+=n;
}
printf("sum=%d\n",s);
return 0;
}
5 0
4 years ago
Other questions:
  • Write a function: function solution(N); that, given a positive integer N, prints the consecutive numbers from 1 to N, each on a
    14·1 answer
  • A rich text format (RTF) provides an electronic image of a document and can be viewed, printed, and electronically transmitted.
    7·1 answer
  • What basic drafting instruments are incorporated in a drafting machine?
    12·1 answer
  • 50 pts. please help ! Explain briefly the role, responsibilities, and required background of the production designer of a film.
    12·1 answer
  • Hi weegy, what is the latest android os?
    9·1 answer
  • When Dale made the decision to sell his stock in copper, he was using a
    12·1 answer
  • Murray University invested over $450,000 in a customized learning management system so that professors could put courses online
    9·1 answer
  • Which is a feature of audio editing software?
    11·2 answers
  • While shopping online, Tucker visits a website that looks outdated and has limited reviews. Which of the following strategies sh
    11·1 answer
  • Data is stored on ________ using a laser to either melt the disc material or change the color of embedded dye.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!