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
Elenna [48]
4 years ago
9

Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and isRed is false. Print "Red balloon" i

f isBalloon and isRed are both true. Print "Not a balloon" otherwise. End with newline.import java.util.Scanner;public class RedBalloon {public static void main (String [] args) {boolean isRed = false;boolean isBalloon = false;using java from there
Computers and Technology
1 answer:
Marat540 [252]4 years ago
6 0

Answer:

if(isBalloon== true && isRed==false) //compare the value of isBalloon variable with true value and isRed variable value with false value.

   System.out.println("Balloon");//Print Balloon

else if(isBalloon== true && isRed==true) //compare the value of isBalloon variable with true value and isRed variable value with also true value.

System.out.println("Red balloon");//Print Red  Balloon

else // when no if condition match it will execute.

System.out.println("Not a balloon"); //Print Not a Balloon

Output:

Not a balloon

Explanation:

The "if-else" statement is defined above for the problem which is given on the question. The detailed explanation of the answer is described below--

  • Firstly we need to check the "true" value for the "isBalloon" variable and "false" value for "isRed" variable. This is done in "if" statement separated with and(&&) operator which gives "true" when both are the true statement.
  • Then we need to check the "true" value for the "isBalloon" variable and "isRed" variable. For this, we need to use "else if" statement which executes when "if" statement is false.
  • Then we need to print the "Not a balloon" statement if both cases are false, for this, we use "else" statement which executes when the "if" and "else if" statement are false.

You might be interested in
Which of the following is NOT one of the Big 3 Google Applications that we discussed?
fredd [130]
I’m thinking C - Word because that isn’t a part of the google family, it’s microsoft.
7 0
4 years ago
Read 2 more answers
Which of the following is not a recommended method to protect you from identity theft?
yaroslaw [1]

Answer:

post them, but id say anything with personal information

7 0
3 years ago
Write a function called simulate_several_key_strikes. It should take one argument: an integer specifying the number of key strik
Furkat [3]

Answer:

The solution code is written in Python 3

  1. import random
  2. import string
  3. def simulate_several_key_strikes(l):
  4.    char_set = string.ascii_lowercase
  5.    return ''.join(random.choice(char_set) for i in range(l))
  6. print (simulate_several_key_strikes(10))

Explanation:

The program is aimed to generate random characters and the number of characters generated is dependent on user input. Hence, we will need to import the random module (Line 1). We also import string module so that we can make use of its associated method to generate English letters (Line 2)

Next, we create the function simulate_several_key_strikes that takes one single parameter, l, as input. Within the function body, we use ascii_lowercase method to generate the lowercase letter set and assign it to char_set variable (Line 5). We use random.choice method to randomly pick one of the letter in char_set and join it with an empty string (Line 6). Please note there is a for-loop that will repeatedly generate l-number of character and eventually return it as output.

We test the function by passing 10 as input parameter and we shall get a sample output as follows:

xuiczuskoj

7 0
3 years ago
Which of the following must be true for hydropower to work?
Nastasia [14]

95% sure its there must be waves

5 0
2 years ago
Ip address 10.10.20.0 255.255.255.224 how many host ip addresses are available in each subnet using this subnet mask?
Maksim231197 [3]
224 = 128 + 64 + 32, so that would mean each network could have 32 nodes. Subtract 2 for the network address and the multicast address, you would have 30 HOST addresses available.
3 0
4 years ago
Other questions:
  • Jamie posted all the journal entries into ledgers. After the postings, Jamie realizes that the debit side of the travel account
    10·1 answer
  • The algorithm ____ is used to find the elements in one range of elements that do not appear in another range of elements.
    5·1 answer
  • _____ are the most fundamental components of designing a training program that determine the amount of stress placed on the body
    6·1 answer
  • The copy constructor for a class is called____________.
    14·1 answer
  • As a prospective student, what is the best reason to request an interview with your college application?
    6·1 answer
  • Disadvantages of computer. ​
    9·1 answer
  • 1. PIN
    10·1 answer
  • What is an a free open source content management system for publishing web content​
    8·1 answer
  • Hi I'm new here can everyone add me as frein ​
    8·1 answer
  • What is hub.pls ans from pic. for computers​
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!