answer.
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
Kay [80]
2 years ago
11

Assignment 1 is to write a program that will write the lyrics to "X number of beers on the wall". Use only the main method. Prom

pt for the initial number of bottles of beer on the wall. Confirm the value is greater than zero and less than 101. Your program should then generate the following console output. The example below assumes the number 3 has entered. You loop each time until there are 0 bottles of beer on the wall. 3 bottles of beer on the wall. 3 bottles of beer. Take 1 down, pass it around. 2 bottles of beer on the wall. 2 bottles of beer on the wall. 2 bottles of beer. Take 1 down, pass it around. 1 bottle of beer on the wall. 1 bottle of beer on the wall. 1 bottle of beer. Take 1 down, pass it around. 0 bottles of beer on the wall.
Computers and Technology
1 answer:
g100num [7]2 years ago
4 0

Answer:

// here is code in java.

import java.util.*;

class Main

{

// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

       // variable to store the number of bottles

       int num_bot;

        Scanner scr=new Scanner(System.in);

        System.out.print("Enter number of bottles of beer on the wall:");

        //read the number of bottles

        num_bot=scr.nextInt();

        // print the output

        for(int i=num_bot;i>0;i--)

        {

         // print the first statement

         System.out.println(i+" beer bottles on the wall");

         // print the second statement

         System.out.println(i+" beer bottles . Take 1 down and pass the bottle around.");

         }

         // when there is 0 bottle

           System.out.println("0 bottles of beer on the wall.");

   }catch(Exception ex){

       return;}

}

}

Explanation:

Declare a variable "num_bot" to store the initial number of beer bottles.Then ask user to give number of bottles.Run a for loop to pass a beer bottle until there is 0 bottle on the wall. When number of bottle is 0 then it will print there is "0 bottle on the wall".

Output:

Enter number of bottles of beer on the wall:3

3 beer bottles on the wall

3 beer bottles . Take 1 down and pass the bottle around.

2 beer bottles on the wall

2 beer bottles . Take 1 down and pass the bottle around.

1 beer bottles on the wall

1 beer bottles . Take 1 down and pass the bottle around.

0 bottles of beer on the wall.

You might be interested in
What are the arguments for writing efficient programs even though hardware is relatively inexpensive?
Ainat [17]

Answer: Even though the hardware is inexpensive the writing of program is not efficient through this method as proper development of program is necessary for the clear execution due to factors like:-

  • The facility of writing program even the cost of hardware is less but it is not a free facility.
  • It also has a slower processing for the execution of the program
  • The construction of the efficient program is necessary for the compilation and execution of it rather than poorly constructed program is worthless and inefficient in working.

7 0
2 years ago
Select the correct answer. Andy wants to become a multimedia producer. Which degree can help him achieve this goal? A. bachelor’
tatuchka [14]

Answer:

C. bachelor’s degree in filmmaking

Explanation:

Because Andy wants to become a multimedia producer, the degree that would best help him achieve his goal is a bachelor's degree in filmmaking.

Multimedia has to do with both audio, video and graphics or animations because it encompasses multiple media files.

Filmmaking has to do with the various forms of making and producing films. Filmmaking has to do with multiple media (multimedia) and it would help him achieve his goal.

7 0
2 years ago
Someone claims that the big O notation does not make sense at all, and they give the following example. An algorithm A that proc
Svetllana [295]

Answer:

Big Oh notation is used to asymptotically bound the growth of running time above and below the constant factor.

Big Oh notation is used to describe time complexity, execution time of an algorithm.

Big Oh describes the worst case to describe time complexity.

For the equation; T(N) = 10000*N + 0.00001*N^3.

To calculate first of all discard all th constants.

And therefore; worst case is the O(N^3).

7 0
2 years ago
You have been tasked with building a URL file validator for a web crawler. A web crawler is an application that fetches a web pa
mixas84 [53]

Answer:

Python Code:

def validate_url(url):

#Creating the list of valid protocols and file name extensions

valid_protocols = ['http', 'https', 'ftp']

valid_fileinfo = ['.html', '.csv', '.docx']

#splitting the url into two parts

url_split = url.split('://')

isProtocolValid = False

isFileValid = False

#iterating over the valid protocols and file names for validity

for x in valid_protocols:

if x in url_split[0]:

isProtocolValid = True

break

for x in valid_fileinfo:

if x in url_split[1]:

isFileValid = True

break

#Returning the result if the URL has both valid protocol and file extension

return (isProtocolValid and isFileValid)

url = input("Enter an URL: ")

print(validate_url(url))

Explanation:

The image of the output code is attached. Hope it helps.

4 0
2 years ago
1- Design a brute-force algorithm for solving the problem below (provide pseudocode): You have a large container with storage si
sladkih [1.3K]

Answer:

Pseudocode is as follows:

// below is a function that takes two parameters:1. An array of items 2. An integer for weight W

// it returns an array of selected items which satisfy the given condition of sum <= max sum.

function findSubset( array items[], integer W)

{

initialize:

maxSum = 0;

ansArray = [];

// take each "item" from array to create all possible combinations of arrays by comparing with "W" and // "maxSum"

start the loop:

// include item in the ansArray[]

ansArray.push(item);

// remove the item from the items[]

items.pop(item);

ansArray.push(item1);

start the while loop(sum(ansArray[]) <= W):

// exclude the element already included and start including till

if (sum(ansArray[]) > maxSum)

// if true then include item in ansArray[]

ansArray.push(item);

// update the maxSum

maxSum = sum(ansArray[items]);

else

// move to next element

continue;

end the loop;

// again make the item[] same by pushing the popped element

items.push(item);

end the loop;

return the ansArray[]

}

Explanation:

You can find example to implement the algorithm.

3 0
2 years ago
Other questions:
  • Carlos owns a hardware store. He currently is not using any software to track what he has in the store. In one to two sentences,
    9·2 answers
  • Propane also known as LP gas, is often mixed with about _______ percent of other gases, such as butane, propylene, and mercaptan
    13·1 answer
  • Assume that the variables gpa, deansList and studentName, have been declared and initialized. Write a statement that adds 1 to d
    13·1 answer
  • In response to a recent outbreak of computer viruses, Babbage Industries, a large technology company, installs computer virus pr
    7·2 answers
  • In a system containing CPU 1 and Disk Drive A, the system is instructed to access Track 1, Track 9, Track 1, and then Track 9 of
    12·1 answer
  • Write multiple if statements: If carYear is before 1968, print "Probably has few safety features." (without quotes). If after 19
    6·1 answer
  • Let's revisit our lucky_number function. We want to change it, so that instead of printing the message, it returns the message.
    10·1 answer
  • Assume you have a project with seven activities labeled A-G (following). Derive the earliest completion time (or early finish-EF
    15·1 answer
  • Which best compares and contrasts visual and performing arts? Both careers use communication skills; however, people involved in
    15·2 answers
  • How does Accenture help companies harness the power of data to achieve optimal business outcomes?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!