Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 1, Problem 1.11PE

(Population projection) The U.S. Census Bureau projects population based on the following assumptions:

  • One birth every 7 seconds
  • One death every 13 seconds
  • One new immigrant every 45 seconds

Write a program to display the population for each of the next five years. Assume that the current population is 312,032,486, and one year has 365 days. Hint: In Java, if two integers perform division, the result is an integer. The fractional part is truncated. For example, 5/4 is 1 (not 1.25) and 10/4 is 2 (not 2.5). To get an accurate result with the fractional part, one of the values involved in the division must be a number with a decimal point. For example, 5.0/4 is 1.25 and 10/4.0 is 2.5.

Blurred answer
Students have asked these similar questions
[Python Language] Using loops of any kind, lists, or Sets is not allowed. Sloan’s Book Collection Sloan loves reading books. She recently started reading an AI generated series called “Harry Trotter”. Sloan is collecting books from the series at her nearest bookstore. Since the series is AI generated, the publishers have produced an infinite collection of the books where each book is identified by a unique integer. The bookstore has exactly one copy of each book. Sloan wants to buy the books in the range [l,r], where l ≤ r. As an example, the range [−3,3] means that Sloan wants to buy the books  − 3,  − 2,  − 1, 0, 1, 2, and 3. Pam also loves the series (or maybe annoying Sloan– who knows, really), and he manages to sneak into the bookstore very early to buy all of the books in the range [d,u], where d ≤ u. When Sloan later visits, sadly she will not find those books there anymore. For example, if Sloan tries to buy books [−2,3] and Pam has bought books [0,2], Sloan would only receive…
use JAVA to write the code. : Euclid’s algorithm for finding the greatest common divisor (gdc) of two numbers The algorithm: given two numbers, n1 and n2: Divide n1 by n2 and let r be the remainder. If the remainder r is 0, the algorithm is finished and the answer is n2. (If the remainder is 1, the numbers are mutually prime and we are done-see below.) Set n1 to the value of n2, set n2 to the value of r, and go back to step 1. Entering 0 for one of the values is bad.  It should work for the other value, but you have to figure out which is OK and which is bad. Catch this problem as it happens and make the user enter another value until they enter an acceptable one. Give an appropriate error message if this happens.
Language: JAVA Leap-Year Write a program to find if a year is a leap year or not. We generally assume that if a year number is divisible by 4 it is a leap year. But it is not the only case. A year is a leap year if − It is evenly divisible by 100 If it is divisible by 100, then it should also be divisible by 400 Except this, all other years evenly divisible by 4 are leap years. So the leap year algorithm is, given the year number Y, Check if Y is divisible by 4 but not 100, DISPLAY "leap year" Check if Y is divisible by 400, DISPLAY "leap year" Otherwise, DISPLAY "not leap year" For this program you have to take the input, that is the year number from an input file input.txt that is provided to you. The input file contains multiple input year numbers. Use a while loop to input the year numbers from the input file one at a time and check if that year is a leap year or not.   Create a class named LeapYear which will contain the main method and write all your code in the main…

Chapter 1 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

Ch. 1.3 - What is an interpreter? What is a compiler?Ch. 1.3 - Prob. 1.3.5CPCh. 1.4 - Prob. 1.4.1CPCh. 1.4 - Prob. 1.4.2CPCh. 1.4 - Prob. 1.4.3CPCh. 1.5 - Who invented Java? Which company owns Java now?Ch. 1.5 - What is a Java applet?Ch. 1.5 - What programming language does Android use?Ch. 1.6 - What is the Java language specification?Ch. 1.6 - Prob. 1.6.2CPCh. 1.6 - Prob. 1.6.3CPCh. 1.6 - Are tools like NetBeans and Eclipse different...Ch. 1.7 - What is a keyword? List some Java keywords.Ch. 1.7 - Prob. 1.7.2CPCh. 1.7 - Prob. 1.7.3CPCh. 1.7 - Prob. 1.7.4CPCh. 1.7 - Prob. 1.7.5CPCh. 1.8 - What is the Java source filename extension, and...Ch. 1.8 - What are the input and output of a Java compiler?Ch. 1.8 - What is the command to compile a Java program?Ch. 1.8 - What is the command to run a Java program?Ch. 1.8 - Prob. 1.8.5CPCh. 1.8 - Prob. 1.8.6CPCh. 1.8 - If a NoClassDefFoundError occurs when you run a...Ch. 1.8 - If a NoSuchMethodError occurs when you run a...Ch. 1.9 - Reformat the following program according to the...Ch. 1.10 - Prob. 1.10.1CPCh. 1.10 - Prob. 1.10.2CPCh. 1.10 - If you forget to put a closing quotation mark on a...Ch. 1.10 - If your program needs to read integers, but the...Ch. 1.10 - Suppose you write a program for computing the...Ch. 1.10 - Identify and fix the errors in the following code:...Ch. 1 - (Display three messages) Write a program that...Ch. 1 - (Display five messages) Write a program that...Ch. 1 - (Display a pattern) Write a program that displays...Ch. 1 - Prob. 1.4PECh. 1 - (Compute expressions) Write a program that...Ch. 1 - (Summation of a series) Write a program that...Ch. 1 - (Approximate ) can be computed using the...Ch. 1 - (Area and perimeter of a circle) Write a program...Ch. 1 - (Area and perimeter of a rectangle) Write a...Ch. 1 - (Average speed in miles) Assume that a runner runs...Ch. 1 - (Population projection) The U.S. Census Bureau...Ch. 1 - (Average speed in kilometers) Assume that a runner...Ch. 1 - (Algebra: solve 2 2 linear equations) You can use...
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
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License