Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
bartleby

Videos

Textbook Question
Book Icon
Chapter 5.1, Problem 5.4CP

What message will the following program display if the user enters 5? What if the user enters 10? What if the user enters 100?

  import javax.swing.J0ptionPane;

  public class Checkpoint

  {

   public static void main(String[ ] args)

   {

    String input;

    int number;

    input = JOptionPane.showInputDialog(“Enter a number.”);

    number = Integer.parseInt(input);

    if (number < 10)

     method1();

    else

     method2();

    System.exit(0);

   }

   public static void method1()

   {

    J0ptionPane.showMessageDialog(nul1, “Able was I.”);

   }

   public static void method2()

   {

    J0ptionPane.showMessageDialog(null, “I saw Elba.”);

   }

  }

Blurred answer
Students have asked these similar questions
What will happen when you compile and run the following code? #1. public class Test{  public static void main(String[] args){  int a = 10, b = 0;  while( a + 2 < 10 || b - 2 > 0){  System.out.println(a);  }  }  }  #2.  public class Test{  public static void main(String[] args){  int a = 0, b = 10;  while(b - 40 > 0){  b -= 2;  while(a + 12 < 10){  a += 2;  if(a == b)  continue;  System.out.print(a + " " + b + ", ");  }  }  }  }    show the output and solution, its java language
What will the following program display?public class Checkpoint{public static void main(String[] args){int a = 10;decrementNum(a);}public static void decrementNum (int n){if (n > 0)DecrementNum (n - 2);elseSystem.out.println(n);    }}
Please help me with this. I am receiving error with this java code below. It keeps being up hello world as the output. A photo is also posted to see what the program that I am trying to create Java program is below import java.util.Random; public class Main { private static String sideUp; void Coin() { toss(); } public static void toss() { Random in = new Random(); int x = in.nextInt(); if (x % 2 == 0) sideUp = "heads"; else sideUp = "tails"; } public static String getFace() { return sideUp; } public static void main(String[] args) { int tail = 0, head = 0; Coin coin = new Coin(); System.out.println("Initial side of coin: " + coin.getFace()); System.out.println("\nTossing coin 20 times:-"); for (int i = 1; i

Chapter 5 Solutions

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

Ch. 5.4 - Prob. 5.11CPCh. 5.4 - Prob. 5.12CPCh. 5.4 - Prob. 5.13CPCh. 5.4 - Prob. 5.14CPCh. 5 - This type of method does not return a value. a....Ch. 5 - Prob. 2MCCh. 5 - Prob. 3MCCh. 5 - Prob. 4MCCh. 5 - A value that is passed into a method when it is...Ch. 5 - Prob. 6MCCh. 5 - Prob. 7MCCh. 5 - Prob. 8MCCh. 5 - Prob. 9MCCh. 5 - True or False: You terminate a method header with...Ch. 5 - Prob. 11TFCh. 5 - Prob. 12TFCh. 5 - Prob. 13TFCh. 5 - Prob. 14TFCh. 5 - Prob. 15TFCh. 5 - Prob. 16TFCh. 5 - Prob. 17TFCh. 5 - True or False: No two methods in the same program...Ch. 5 - True or False: It is possible for one method to...Ch. 5 - True or False: You must have a return statement in...Ch. 5 - Prob. 1FTECh. 5 - Look at the following method header: public static...Ch. 5 - Prob. 3FTECh. 5 - Prob. 4FTECh. 5 - Prob. 1AWCh. 5 - Here is the code for the displayValue method,...Ch. 5 - Prob. 3AWCh. 5 - What will the following program display? public...Ch. 5 - A program contains the following method...Ch. 5 - Prob. 6AWCh. 5 - Prob. 7AWCh. 5 - Write a method named square that accepts an...Ch. 5 - Write a method named getName that prompts the user...Ch. 5 - Write a method named quartersToDol1ars. The method...Ch. 5 - Prob. 1SACh. 5 - Prob. 2SACh. 5 - What is the difference between an argument and a...Ch. 5 - Where do you declare a parameter variable?Ch. 5 - Prob. 5SACh. 5 - Prob. 6SACh. 5 - Prob. 1PCCh. 5 - Retail Price Calculator Write a program that asks...Ch. 5 - Rectangle AreaComplete the Program If you have...Ch. 5 - Paint Job Estimator A painting company has...Ch. 5 - Prob. 5PCCh. 5 - Celsius Temperature Table The formula for...Ch. 5 - Test Average and Grade Write a program that asks...Ch. 5 - Conversion Program Write a program that asks the...Ch. 5 - Distance TraveLed Modification The distance a...Ch. 5 - Stock Profit The profit from the sale of a stock...Ch. 5 - Multiple Stock Sales Use the method that you wrote...Ch. 5 - Kinetic Energy In physics, an object that is in...Ch. 5 - isPrime Method A prime number is a number that is...Ch. 5 - Prime Number List Use the isPrime method that you...Ch. 5 - Even/Odd Counter You can use the following logic...Ch. 5 - Present Value Suppose you want to deposit a...Ch. 5 - Rock, Paper, Scissors Game Write a program that...Ch. 5 - ESP Game Write a program that tests your ESP...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
The Top Down Approach to Software Development; Author: Christopher Kalodikis;https://www.youtube.com/watch?v=v9M8LA2uM48;License: Standard YouTube License, CC-BY