Similar Books


    No books found

Title
Chapter: 6 / Q: 24
(Display current date and time) Listing 2.7, ShowCurrentTime.java, displays the current time. Improve this example to display the current date and time. The calendar example in Listing 6.12, PrintCalendar.java, should give you some ideas on how to find the year, month, and day
Chapter: 6 / Q: 25
(Convert milliseconds to hours, minutes, and seconds) Write a method that converts milliseconds to hours, minutes, and seconds using the following header:
Chapter: 6 / Q: 26
(Palindromic prime) A palindromic prime is a prime number and also palindromic. For example, 131 is a prime and also a palindromic prime, as are 313 and 757. Write a program that displays the first 100 palindromic prime numbers. Display 10 numbers per line, separated by exactly one space, as follows
Chapter: 6 / Q: 27
(Emirp) An emirp (prime spelled backward) is a nonpalindromic prime number whose reversal is also a prime. For example, 17 is a prime and 71 is a prime, so 17 and 71 are emirps. Write a program that displays the first 100 emirps. Display 10 numbers per line, separated by exactly one space, as follow
Chapter: 6 / Q: 28
(Mersenne prime) A prime number is called a Mersenne prime if it can be written in the form 2p - 1 for some positive integer p. Write a program that finds all Mersenne primes with p≤ 31 and displays the output as follows:
Chapter: 6 / Q: 29
(Twin primes) Twin primes are a pair of prime numbers that differ by 2. For example, 3 and 5 are twin primes, 5 and 7 are twin primes, and 11 and 13 are twin primes. Write a program to find all twin primes less than 1,000. Display the output as follows:
Chapter: 6 / Q: 30
(Game: craps) Craps is a popular dice game played in casinos. Write a program to play a variation of the game, as follows:
Chapter: 6 / Q: 31
(Financial: credit card number validation) Credit card numbers follow certain patterns. A credit card number must have between 13 and 16 digits. It must start with:
Chapter: 6 / Q: 32
(Game: chance of winning at craps) Revise Exercise 6.30 to run it 10,000 times and display the number of winning games
Chapter: 6 / Q: 33
(Current date and time) Invoking System.currentTimeMillis() returns the elapsed time in milliseconds since midnight of January 1, 1970. Write a program that displays the date and time. Here is a sample run:
total questions: 772

Questions

772

Views

A PHP Error was encountered

Severity: Warning

Message: Undefined property: stdClass::$TotalViews

Filename: books/book.php

Line Number: 411

Best Answers

299

Points

5