bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 3.1, Problem 10STQ

What output is produced by the following code?

int time = 2, tide = 3;

if (time + tide > 6)

System.out.println(“Time and tide wait for no one.”);

else if (time + tide > 5)

System.out.println(“Time and tide wait for someone.”);

else if (time + tide > 4)

System.out.println(“Time and tide wait for everyone.”);

else

System.out.println(“Time and tide wait for me.”);

Blurred answer
Students have asked these similar questions
What is the output of the following, if n=1, n=2, n=3, n=4, and n=5, respectively?   int n = scan.nextInt(); switch (n) { case 1: case 2:        System.out.print(“less than 3”);        break; case 3: case 4:       System.out.print(“less than 5 but bigger than 2”);       break; default:      System.out.print(“Other situations”); }
THIS IS IN JAVA Given x = 1, y = 2, and z = 3, how is the expression evaluated? In the choices, items in parentheses are evaluated first. <pre><code>(x == 5) || (y == 2) && (z == 5)</code></pre>       A. false OR (true AND false) --> false OR false --> false B. false OR (true AND false) --> false OR true --> true C. (false OR true) AND false --> true AND false --> false D. (false OR true) AND false --> true AND false --> true
Write a program that calculates the estimated hours and minutes for a trip given the number of miles traveled and the speed in miles per hour. Specifically, write a program that Welcomes the user to the Travel Time Calculator. Asks user for number of miles traveled(allow user to enter fractional values) Asks user for the speed in miles per hour (allow user to enter fractional values) Calculates the number of hours and minutes for the trip to the nearest integer value. Hint: You can use the built-in function round that rounds a given number to the rounded integer value. e.g. round(4) will return 4, round(4.125) will return 4, round(4.5) will return 4 and round (4.75) will return 5. Prints the number of hours and minutes for the trip. Here are some sample runs:

Chapter 3 Solutions

Java: An Introduction to Problem Solving and Programming plus MyProgrammingLab with Pearson eText -- Access Card Package (7th Edition)

Ch. 3.2 - Suppose number is a variable of type int that has...Ch. 3.2 - What output is produced by the following...Ch. 3.2 - What output is produced by the following...Ch. 3.2 - What output is produced by the following...Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - Suppose you change the code in the previous...Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - What output is produced by the following code?Ch. 3.3 - Suppose you change the first line of the code in...Ch. 3.3 - Prob. 20STQCh. 3.4 - Prob. 21STQCh. 3.4 - Prob. 22STQCh. 3.4 - Write code for a JOptionPane dialog that will ask...Ch. 3 - Write a fragment of code that will test whether an...Ch. 3 - Write a fragment of code that will change the...Ch. 3 - Suppose you are writing a program that asks the...Ch. 3 - Prob. 4ECh. 3 - Consider the following fragment of code: What is...Ch. 3 - We would like to assess a service charge for...Ch. 3 - What is the value of each of the following boolean...Ch. 3 - The following code fragment will not compile. Why?...Ch. 3 - Prob. 9ECh. 3 - Consider the boolean expression (2 5) (x 100))....Ch. 3 - Write a switch statement to convert a letter grade...Ch. 3 - Consider the previous question, but include + or ...Ch. 3 - Imagine a program that displays a menu of five...Ch. 3 - Repeat the previous exercise, but define an...Ch. 3 - Repeat Exercise 13, but use a multibranch if-else...Ch. 3 - Given that the int variable temp contains a...Ch. 3 - Write Java statements that create a yes-or-no...Ch. 3 - A number x is divisible by y if the remainder...Ch. 3 - Write a program to read in three nonnegative...Ch. 3 - Write a program that reads three strings from the...Ch. 3 - Write a program that reads a one-line sentence as...Ch. 3 - Write a program that allows the user to convert a...Ch. 3 - Write a program that inputs an integer. If the...Ch. 3 - Prob. 7PCh. 3 - Repeat Programming Project 5 of Chapter 2, but...Ch. 3 - Repeat any of the previous Practice Programs using...Ch. 3 - Suppose that we are working for an online service...Ch. 3 - Write a program that reads a string from the...Ch. 3 - Repeat the calorie-counting program described in...Ch. 3 - Repeat Programming Project 5 but in addition ask...Ch. 3 - Repeat Programming Project 11 in Chapter 2, but if...Ch. 3 - Write a program to play the rock-paper-scissor...Ch. 3 - Prob. 9PPCh. 3 - Repeat Programming Project 8 in Chapter 1, but add...
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
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY