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]
3 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]3 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
Create a program that allows the user to pick and enter a low and a high number. Your program should generate 10 random numbers
Natalka [10]

Answer:

import java.util.Scanner;

import java.util.Arrays;

import java.util.Random;

public class Main {

 public static void main(String[] args) {

   Scanner scan = new Scanner(System.in);

   System.out.print("Enter low: ");

   int low = scan.nextInt();

   System.out.print("Enter high: ");

   int high  = scan.nextInt();

   scan.close();

   int rndnumbers[] = new int[10];

   Random r = new Random();

   for(int i=0; i<rndnumbers.length; i++) {

     rndnumbers[i] = r.nextInt(high-low+1) + low;

   }

   for(int i=0; i<rndnumbers.length; i++) {

     System.out.printf("%d: %d\n", i, rndnumbers[i]);

   }

 }

}

4 0
3 years ago
What is a tag in an HTML document?
Llana [10]

Answer: HTML is considered as the Lingua franca of the net that is a simple mark up language used for the purpose of web publishing for creating text and images. This can be viewed by any of the member and can be used within any browser. There is no need of special software for creating HTML pages and moreover the learning of HTML is pretty easy.

Explanation: If you need more help go follow me at dr.darrien

- thank you

3 0
3 years ago
Read 2 more answers
why is it useful to learn how to solve and program solutions with a limited set of command in computer science
12345 [234]

Answer:

Give at least one reason why it's useful to learn how to solve and program solutions with a limited set of commands. So that when there is more commands we know how to use the ones we have. parameters help generalize the solution to a specific problem. how are functions with parameters an example of abstraction?

4 0
2 years ago
Why are using some special characters (@, #, !, etc.) not a good idea?
konstantin123 [22]
There are pros and cons to using special characters in email subject lines. Generally, marketers report higher open rates.

Some report better engagement, but many don’t.

There are also reports of special characters causing problems with deliverability, mostly because spammers became very fond of special characters for a while.
5 0
3 years ago
Read 2 more answers
Which of the given original work is protected by the copyright law?
Mila [183]

Answer:i would love to help but are there any answer choices?

Explanation: please provide answer choices for an accurate answer

6 0
3 years ago
Other questions:
  • Can someone please help me with this question?
    12·1 answer
  • Why is it a good idea to view your HTML code in more than one web browser
    13·1 answer
  • How many worksheets display in the Excel window when you create a new blank workbook?
    10·2 answers
  • A tracking signal A. is computed as the mean absolute deviation​ (MAD) divided by the running sum of the forecast errors​ (RSFE)
    10·1 answer
  • Select the correct answer.
    14·2 answers
  • Which cable would you check if you can't access any web pages?
    12·1 answer
  • Which statistical measurement tools should be
    8·1 answer
  • Which statement about intellectual property is true? (CSI-7.6) Group of answer choices It is okay to use code you find on the in
    14·1 answer
  • 1)What is the hydropower resources/energy?
    7·1 answer
  • When Alice turned on her laptop this morning, the screen displayed only colorful horizontal lines. Which of the following is mos
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!