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
Write a script that inputs a line of encrypted text and a distance value and outputs plaintext using a Caesar cipher. The script
jenyasd209 [6]

Answer:

# Request the inputs

codedText = input("Enter the coded text: ")

distance = int(input("Enter the distance value: "))

# Calculate the decryption

# see comment for the rest. Brainly won't let me save an answer which contains code.

Explanation:

Above is your program fixed, but it is unclear on how to deal with unprintable characters, i.e., characters that originally were near the highest printable character ('~')

4 0
2 years ago
Ben's team is working on an English project. The members want to see everyone's progress on their part of the project. What tech
Kruka [31]
Web conferencing would allow you to communicate freely with the team but cloud computing allows you to share data between the group. The answer would be A. Cloud Computing
7 0
2 years ago
Read 2 more answers
How many solutions exist for the given equation?
vovikov84 [41]
Infinity amount of answers because each side can be simplified to x making any solution correct
6 0
2 years ago
Seneca has just applied conditional formatting and realizes that she has made a mistake. Which action should she take to fix the
Mama L [17]

Answer:

its b

Explanation:

on edg

3 0
2 years ago
Read 2 more answers
What are the pros and cons of using unique closing reserved words on compound statements?
Nata [24]

Pros: Readability. Unique closing reserved words on compound statements will enhance readability and flexibility of a language. When an endwhile or an endif in a program is written by someone else, it is vivid which block is ending. Using braces is much harder is sometimes much harder to read.

Cons: Writability. They have the disadvantage of writability and thus, complicating the language by increasing the number of keywords. Use of more of these reserved words mean less words available for the programmer.







6 0
2 years ago
Other questions:
  • When a button is selected, the computer processes the code contained in the buttons ____ event procedure?
    12·1 answer
  • Which type of broadband internet access involves using cellular data networks? ​?
    13·1 answer
  • Enter a formula in cell B10 to return a value of 35000 if the Net Profit After Tax (cell B9) is greater than or equal to 470000
    15·2 answers
  • Joe runs a handyman service. He enjoys writing and keeping up on the latest trends. He wants to share this information with his
    7·1 answer
  • Why would someone need to use tools like IECacheView or MyLastSearch on a system? Do companies have the right to search a workst
    11·1 answer
  • You complete your database, and the company begins using it. Shortly afterwards, two GearUp buyers, Cora and Owen, work together
    9·1 answer
  • A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
    10·1 answer
  • Drag each tile to the correct box.
    12·1 answer
  • Given a sorted list of integers, output the middle integer. A negative number indicates the end of the input (the negative numbe
    13·1 answer
  • Assign total_owls with the sum of num_owls_A and num_owls_B.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!