New Semester
Started
Get
50% OFF
Study Help!
--h --m --s
Claim Now
Question Answers
Textbooks
Find textbooks, questions and answers
Oops, something went wrong!
Change your search query and then try again
S
Books
FREE
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Tutors
Online Tutors
Find a Tutor
Hire a Tutor
Become a Tutor
AI Tutor
AI Study Planner
NEW
Sell Books
Search
Search
Sign In
Register
study help
computer science
java how to program early objects
Java How To Program Early Objects 11th Edition Paul Deitel, Harvey Deitel - Solutions
Answer each of the following questions:a) What does it mean to choose numbers “at random”?b) Why is the nextInt method of class SecureRandom useful for simulating games of chance?c) Why is it often necessary to scale or shift the values produced by a SecureRandom object?d) Why is computerized
What is the value of x after each of the following statements is executed?a) double x = Math.abs(7.5);b) double x = Math.floor(7.5);c) double x = Math.abs(0.0);d) double x = Math.ceil(0.0);e) double x = Math.abs(-6.4);f) double x = Math.ceil(-6.4);g) double x = Math.ceil(-Math.abs(-8 +
Declare method sphereVolume to calculate and return the volume of the sphere. Use the following statement to calculate the volume:double volume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3)Write a Java application that prompts the user for the double radius of a sphere, calls sphereVolume to
Find the error in each of the following program segments. Explain how to correct the error. a) void g() { System.out.println("Inside method g"); void h() { System.out.println("Inside method h"); } }b)
Fill in the blanks in each of the following statements:a. A method is invoked with a(n) .b.
Describe in general how you’d remove any continue statement from a loop in a program and replace it with some structured equivalent. Use the technique you develop here to remove the continue statement from the program in Fig. 5.14.
What does the following program segment do? for (i = 1; i <= 5; i++) { for (j = 1; j <= 3; j++) { for (k = 1; k <= 4; k++) { System.out.print('*'); } System.out.println(); }
A criticism of the break statement and the continue statement is that each is unstructured. Actually, these statements can always be replaced by structured statements, although doing so can be awkward. Describe in general how you’d remove any break statement from a loop in a program and replace
Calculate the value of π from the infinite seriesPrint a table that shows the value of p approximated by computing the first 200,000 terms of this series. How many terms do you have to use before you first get a value that begins with 3.14159? 4. 4 4 4 4 I = 4 3579 11 +
Assume that i = 1, j = 2, k = 3 and m = 2. What does each of the following statements print?a) System.out.println(i == 1);b) System.out.println(j == 3);c) System.out.println((i >= 1) && (j < 4));d) System.out.println((m <= 99) & (k < m));e) System.out.println((j >= i) ||
Factorials are used frequently in probability problems. The factorial of a positive integer n (written n! and pronounced “n factorial”) is equal to the product of the positive integers from 1 to n. Write an application that calculates the factorials of 1 through 20. Use type long. Display the
What does the following program do? public class Printing { public static void main(String[] args) { for (int i = 1; i <= 10; i++) { for (int j = 1; j <= 5; j++) { System.out.print('@'); }
Compare and contrast the while and for iteration statements.
Find the error in each of the following code segments, and explain how to correct it: a) i = 1; while (i <= 10); ++i; }b) for (k = 0.1; k != 1.0; k += 0.1) { System.out.println(k); }c)
a) Sum the odd integers between 1 and 99, using a for statement. Assume that the integer variables sum and count have been declared.b) Calculate the value of 2.5 raised to the power of 3, using the pow method.c) Print the integers from 1 to 20, using a while loop and the counter variable i. Assume
State whether each of the following is true or false. If false, explain why.a) The default case is required in the switch selection statement.b) The break statement is required in the last case of a switch selection statement.c) The expression ((x > y) && (a < b)) is true if either x
Fill in the blanks in each of the following statements:a) Typically, _____________ statements are used for counter-controlled iteration and statements for sentinel-controlled iteration.b) The do…while statement tests the loop-continuation condition executing the loop’s body;
What is wrong with the following statement? Provide the correct statement to add one to the sum of x and y.System.out.println(++(x + y));
Write an application that keeps displaying in the command window the multiples of the integer 2—namely, 2, 4, 8, 16, 32, 64, and so on. Your loop should not terminate (i.e., it should create an infinite loop). What happens when you run this pro- gram?
Based on the dangling-else discussion in Exercise 4.27, modify the following code to produce the output shown. Use proper indentation techniques. You must not make any additional changes other than inserting braces and changing the code’s inden- tation. We’ve eliminated the indentation from the
Based on the dangling-else discussion in Exercise 4.27, state the output for each of the following code segments when x is 9 and y is 11 and when x is 11 and y is 9. We eliminated the indentation from the following code to make the problem more chal- lenging. Apply the indentation conventions
What does the following program print? // Exercise 4.26: Mystery3.java 2 public class Mystery3 { 3 public static void main(String [] args) { 4 5 int row = 10; 6 while (row >= 1) { 7 int column - 1; 8 while (column
What does the following program print?public class Mystery2 {public static void main(String[] args) {int count = 1; while (count <= 10) {
What does the following program print?public class Mystery {public static void main(String[] args) {int x = 1;int total = 0; while (x <= 10) {int y = x * x;System.out.println(y);total
Identify and correct the errors in each of the following pieces of code. a)int x = 1, total;while (x <= 10) {total += x;++x;}b)while (x <= 100)total += x;++x;c)while (y > 0) {aSystem.out.println(y);++y;
What is the difference between preincrementing and postincrementing a variable?
Explain what happens when a Java program attempts to divide one integer by another. What happens to the fractional part of the calculation? How can you avoid that outcome?
Compare and contrast the if single-selection statement and the while iteration statement. How are these two statements similar? How are they different?
What is wrong with the following while statement?while (z >= 0) {sum += z;}
Identify and correct the errors in each of the following code segments—assume that all vari- ables have been properly declared and initialized:a)while (c <= 5) {product *= c;++c;b)if (gender == 1) {System.out.println("Woman");}else; {System.out.println("Man");}
Determine the value of the variables in the statement product *= x++; after the calculation is performed. Assume that all variables are type int and initially have the value 5.
Write Java statements to accomplish each of the following tasks:a) Use one statement to assign the sum of x and y to z, then increment x by 1.b) Test whether variable count is greater than 10. If it is, print "Count is greater than 10".c) Use one statement to decrement the variable x by 1, then
Write four different Java statements that each add 1 to integer variable x.
State whether each of the following is true or false. If false, explain why.a) An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which they execute.b) A set of statements contained within a pair of parentheses is called a block.c) A selection
Fill in the blanks in each of the following statements:a. All programs can be written in terms of three types of control structures: ,
Explain why a class might provide a set method and a get method for an instance variable.
Explain how a program could use class Scanner with- out importing it.
Most classes need to be imported before they can be used in an app. Why is every app allowed to use classes System and String without first importing them?
What’s the purpose of keyword new? Explain what happens when you use it.
Explain the purpose of a method parameter. What is the difference between a parameter and an argument?
State whether each of the following is true or false. If false, explain why.a) By convention, method names begin with an uppercase first letter, and all subsequent words in the name begin with a capital first letter.b) An import declaration is not required when one class in a package uses another
What does the following code print?System.out.printf("%s%n%s%n%s%n", "*", "***", "*****");
What does the following code print?System.out.print("*"); System.out.println("***"); System.out.println("*****"); System.out.print("****"); System.out.println("**");
What does the following code print?System.out.print("*"); System.out.print("***"); System.out.print("*****"); System.out.print("****"); System.out.println("**");
What does the following code print?System.out.println("*"); System.out.println("***"); System.out.println("*****"); System.out.println("****"); System.out.println("**");
Assuming that x = 2 and y = 3, what does each of the following statements display?a) System.out.printf("x = %d%n", x);b) System.out.printf("Value of %d + %d is %d%n", x, x, (x + x));c) System.out.printf("x =");d) System.out.printf("%d = %d%n", (x + y), (y + x));
State whether each of the following is true or false. If false, explain why.a) Java operators are evaluated from left to right.b) The following are all valid variable names: _under_bar_, m928134, t5, j7, her_sales$, his_$account_total, a, b$, c, z and z2.c) A valid Java arithmetic expression with
Fill in the blanks in each of the following statements:a. are used to document a program and improve its readability.b. A decision can be made in a Java program with a(n) .c.
Write statements to accomplish each of the following tasks:a) Declare variables c, thisIsAVariable, q76354 and number to be of type int and initialize each to 0.b) Prompt the user to enter an integer.c) Input an integer and assign the result to int variable value. Assume Scanner variable input can
State whether each of the following is true or false. If false, explain why.a) Comments cause the computer to display the text after the // on the screen when the program executes.b) All variables must be given a type when they’re declared.c) Java considers the variables number and NuMbEr to be
Fill in the blanks in each of the following statements:a) A(n) _________ and a(n) _________ begin and end the body of every method.b) You can use the _________ statement to make decisions.c) _________ begins an end-of-line comment.d) _________, _________and are called white space.e) _________ are
It’s now possible to have a microprocessor at the heart of just about any device and to connect those devices to the Internet. This has led to the notion of the Internet of Things (IoT), which already interconnects tens of billions of devices. Research the IoT and indicate the many ways it’s
Research the rapidly growing field of big data. List applications that hold great promise in fields such as healthcare and scientific research.
Developments in the field of artificial intelligence have been accelerating in recent years. Many companies now offer computerized intelligent assistants, such as IBM’s Watson, Amazon’s Alexa, Apple’s Siri, Google’s Google Now and Microsoft’s Cortana. Research these and others and list
By recent estimates, two-thirds of the people in the United States are overweight and about half of those are obese. This causes significant increases in illnesses such as diabetes and heart disease. To determine whether a person is overweight or obese, you can use a measure called the body mass
One of the world’s most common objects is a wrist watch. Discuss how each of the following terms and concepts applies to the notion of a watch: object, attributes, behaviors, class, inheritance (consider, for example, an alarm clock), modeling, messages, encapsulation, interface and information
Explain the two compilation phases of Java programs.
Fill in the blanks in each of the following statements:a) The programming language is now used to develop large-scale enterprise applications, to enhance the functionality of web servers, to provide applications for consumer devices and for many other purposes.b) initially became widely known as
Fill in the blanks in each of the following statements:a) The logical unit that receives information from outside the computer for use by the computer is the _________.b) The process of instructing the computer to solve a problem is called _________.c) _________ is a type of computer language that
Fill in the blanks in each of the following statements (based on Section 1.5): a) Objects enable the design practice of __________ although they may know how to communicate with one another across well-defined interfaces, they normally are not allowed to know how other objects are
Fill in the blanks in each of the following sentences about the Java environment:a) The __________ command from the JDK executes a Java application.b) The __________ command from the JDK compiles a Java program.c) A Java source code file must end with the __________ file extension.d) When a Java
Fill in the blanks in each of the following statements:a) Computers process data under the control of sets of instructions called __________.b) The key logical units of the computer are the , , ,, and __________.c) The three types of languages discussed in the chapter are , and __________.d) The
Showing 100 - 200
of 162
1
2
Step by Step Answers