• Home
  • Textbooks
  • Introduction to Programming with Java: A Problem Solving Approach
  • Using Pre-Built Methods

Introduction to Programming with Java: A Problem Solving Approach

John S. Dean, Raymond H. Dean

Chapter 5

Using Pre-Built Methods - all with Video Answers

Educators


Chapter Questions

01:08

Problem 1

Given these declarations:
double diameter $=3.0$
double perimeter:
Provide a statement that assigns the length of a circle's perimeter to the perimeter variable. Use the diameter variable.

Pammi Eswari
Pammi Eswari
Numerade Educator
01:45

Problem 2

What is the name of the class that contains the abs, min, and round methods?
a) Arithmetic
b) Math
c) Number

Arin Asawa
Arin Asawa
Numerade Educator
01:45

Problem 3

Provide a statement that assigns positive infinity into a double variable named num.

Ma. Theresa  Alin
Ma. Theresa Alin
Numerade Educator
02:56

Problem 4

Provide a statement that converts a string variable named s to a 1 ong and assigns the result to a 1 ong variable named num.

Adriano Chikande
Adriano Chikande
Numerade Educator
02:56

Problem 5

Provide a statement that converts an int variable named num to a string and assigns the result to a String variable named numStr. Use a wrapper class method.

Adriano Chikande
Adriano Chikande
Numerade Educator
00:49

Problem 6

What does the following code fragment print?
System.out.println(Character.isDigit('#'));
System.out.println(Character.isWhitespace('\t'));
System.out.println(Character.toLowerCase('B'));

Ernest Castorena
Ernest Castorena
Numerade Educator
01:47

Problem 7

Given this declaration:
String snyder $=$ "Stick together. InLearn the flowers. InGo light."
Write a Java statement that finds the index of the letter "G' and prints everything in snyder from that point
on. In other words, it prints Go light.

Vysakh M
Vysakh M
Numerade Educator
07:19

Problem 8

Write a format string that handles the display of three data items in three columns. The first column should be 20 spaces wide, and it should print a left-aligned string. The second column should be 10 spaces wide, and it should print a right-aligned integer. The third column should be 16 spaces wide, and it should print a right-aligned floating-point number in scientific format with 6 decimal places. Your format string should cause the screen's cursor to move to the next line after printing the third data item.

RO
Reynald Oliveria
Numerade Educator
01:13

Problem 9

Provide a format specifier that handles the display of a floating-point data item. It should print a rounded version of the data item with no decimal places. It should insert grouping separators, and it should use parentheses if the number is negative.

Ernest Castorena
Ernest Castorena
Numerade Educator
05:12

Problem 10

Write a Java statement that prints a random number for the total number of dots on a roll of a pair of dice.

Harriet O'Brien
Harriet O'Brien
Numerade Educator
02:21

Problem 11

Write a program that prints five random boolean values with the seed, 123 L. Then display those values.

Harriet O'Brien
Harriet O'Brien
Numerade Educator