Big Java Late Objects
Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
bartleby

Videos

Textbook Question
Book Icon
Chapter 5, Problem 1RE

In which sequence are the lines of the Cubes.java program in Section 5.2 executed, starting with the first line of main?

Expert Solution & Answer
Check Mark
Program Plan Intro

Introduction:

  • Define the class named “Cubes”.
  • Define the main method.
  • Declare and assign the required variables.
  • Print the volume of the cube with length of the side as “2”.
  • Print the volume of the cube with length of the side as “10”.
  • Define the static method named “cubeVolume”.
  • Declare and assign the required double variable.
  • Return the value stored in the variable “volume”.

Explanation of Solution

//define a class

public class Cubes

{

    //define the main method

    public static void main(String[] args)

    {

        //declare the required variables

        double result1=cubeVolume(2);

        double result2=cubeVolume(10);

        //print the output statements

        System.out.println("A cube with side length 2 has

  volume"

  +result1);

        System.out.println("A cube with side length 10

  has volume"

  +result2);

    }

    //define the static method

    public static double cubeVolume(double sideLength)

    {

        //declare the required variables

        double volume=sideLength*sideLength*sideLength;

        //return statement

        return volume;

    }

}

Sample Output

A cube with side length 2 has volume 8

A cube with side length 10 has volume 1000

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
how to answer the follow question in java In between is a well-known card game. Many variations exist- we define it as follows. One deck of card is used. A game consist of one or more hands. A player starts with a certain number of chips called the stake (say 100) and must risk one or more chips on each hand, before seeing any cards, as long as the player still has chips and there are three or more card left in the desk(enough to play one hand), the game continues. For each hand player must risk the player For each hand the player must risk between one and their total number of chips. Two cards are dealt face up. Then the third card is dealt. If the third card is in between the first two cards, based on ranks of the cards, the player’s chips are increase by the amount risked. Otherwise they decreased by the amount. A implement the game. The application user is the player (GUI not require) (only three cards is required to play). If the first two cards are the same rank, that hand is…
Please answer in Java 1. A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design the class Point that can store and process a point in the x-y plane.-We should then perform operations on a point, such as showing the point, setting the coordinates of the point, printing the coordinates of the point, returning the x-coordinate, and returning the y-coordinate. -Write a test program to test various operations on a point.  The class Point should contain the following methods and data members: 1. protected members x and y2. default constructors3. constructors with parameters4. setPoint(x)5. getX()6. getY()7. toString()8. equals(x)9. makeCopy(x)10. getCopy()11. printPoint()  The output should show the following: -Initialize myPoint = [5.00,4.00]-Initialize yourPoint = [0.00, 0.00]-Print both of these objects-Set yourPoint to [5.00, 45.00] and print it-Determine if the 2 points are equal or not-Change the myPoint coordinates to [6.00, 9.00]-Print this new myPoint…
Write up Java source codes for compiling and execution of program below. Draw UML diagram for codes. There is a very simple solution to keeping Tic-tac-toe fresh and interesting, though, and it has been thought up by a group of mathematicians. It’s being called Ultimate Tic-tac-toe and simply embeds a Tic-tac-toe board in each of the nine squares of the original game. Now instead of just winning the main board, you also need to win each of the smaller boards first until you have a line of three. New Rule: You can only place a mark on the board determined by the position of your opponent’s last placed mark. So, if they put an X or O in the top right corner of a square, your next move must occur in the top right board. By adding that rule the game is no longer about winning a single board, it’s about tactically managing up to 9 games at once and plotting ahead. You still win by marking three squares in a row, but that now involves winning three games.   The effects of the New Rule: 1:…

Chapter 5 Solutions

Big Java Late Objects

Ch. 5.3 - Prob. 11SCCh. 5.3 - What does this program print? Use a diagram like...Ch. 5.4 - Prob. 13SCCh. 5.4 - What does this method do? public static boolean...Ch. 5.4 - Implement the mystery method of Self Check 14 with...Ch. 5.5 - How do you generate the following printout, using...Ch. 5.5 - Prob. 17SCCh. 5.5 - Prob. 18SCCh. 5.5 - Prob. 19SCCh. 5.5 - The boxString method contains the code for...Ch. 5.6 - Consider the following statements: int...Ch. 5.6 - Consider this method that prints a page number on...Ch. 5.6 - Consider the following method that computes...Ch. 5.6 - The comment explains what the following loop does....Ch. 5.6 - In Self Check 24, you were asked to implement a...Ch. 5.7 - Explain how you can improve the intName method so...Ch. 5.7 - Prob. 27SCCh. 5.7 - What happens when you call intName(0)? How can you...Ch. 5.7 - Trace the method call intName(72), as described in...Ch. 5.7 - Prob. 30SCCh. 5.8 - Which lines are in the scope of the variable i...Ch. 5.8 - Which lines are in the scope of the parameter...Ch. 5.8 - The program declares two local variables with the...Ch. 5.8 - There is a scope error in the mystery method. How...Ch. 5.8 - Prob. 35SCCh. 5.9 - Consider this slight modification of the...Ch. 5.9 - Consider this recursive method: public static int...Ch. 5.9 - Consider this recursive method: public static int...Ch. 5.9 - Prob. 39SCCh. 5.9 - The intName method in Section 5.7 accepted...Ch. 5 - In which sequence are the lines of the Cubes.java...Ch. 5 - Write method headers for methods with the...Ch. 5 - Give examples of the following methods from the...Ch. 5 - Prob. 4RECh. 5 - Consider these methods: public static double...Ch. 5 - Prob. 6RECh. 5 - Design a method that prints a floating-point...Ch. 5 - Write pseudocode for a method that translates a...Ch. 5 - Describe the scope error in the following program...Ch. 5 - For each of the variables in the following...Ch. 5 - Prob. 11RECh. 5 - Perform a walkthrough of the intName method with...Ch. 5 - Consider the following method: public static int...Ch. 5 - Consider the following method that is intended to...Ch. 5 - Suppose an ancient civilization had constructed...Ch. 5 - Give pseudocode for a recursive method for...Ch. 5 - Give pseudocode for a recursive method that sorts...Ch. 5 - Write the following methods and provide a program...Ch. 5 - Write the following methods and provide a program...Ch. 5 - Prob. 4PECh. 5 - Prob. 5PECh. 5 - Prob. 6PECh. 5 - Prob. 7PECh. 5 - Prob. 8PECh. 5 - Write methods public static double...Ch. 5 - Write a recursive method public static String...Ch. 5 - Write a recursive method public static boolean...Ch. 5 - Use recursion to implement a method public static...Ch. 5 - Use recursion to determine the number of digits in...Ch. 5 - Write a method that computes the balance of a bank...Ch. 5 - Write a method that tests whether a file name...Ch. 5 - It is a well-known phenomenon that most people are...Ch. 5 - Prob. 3PPCh. 5 - Use recursion to compute an, where n is a positive...Ch. 5 - Leap years. Write a method public static boolean...Ch. 5 - In Exercise P3.13 you were asked to write a...Ch. 5 - Prob. 10PPCh. 5 - Write a program that reads two strings containing...Ch. 5 - Prob. 12PPCh. 5 - Write a program that reads words and arranges them...Ch. 5 - Prob. 14PPCh. 5 - Write a program that reads two fractions, adds...Ch. 5 - Write a program that prints the decimal expansion...Ch. 5 - Write a program that reads a decimal expansion...Ch. 5 - Write two methods public static void...Ch. 5 - Write a program that reads in the width and height...Ch. 5 - Repeat Exercise P5.19 with hexagonal circle...Ch. 5 - Postal bar codes. For faster sorting of letters,...Ch. 5 - Write a program that reads in a bar code (with :...Ch. 5 - Write a program that converts a Roman number such...Ch. 5 - A non-governmental organization needs a program to...Ch. 5 - Having a secure password is a very important...Ch. 5 - Prob. 30PPCh. 5 - Prob. 31PPCh. 5 - Electric wire, like that in the photo, is a...Ch. 5 - The drag force on a car is given by FD=12v2ACD...
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
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY