Question: Submit Filename: Exercise1_4M.java (Ninth Edition Page 31 1.4 Modified; 10th Edition Page 30 1.4) Submit Filename: Population.java (Ninth Edition Page 32 1.11 Modified; 10th Edition

Submit Filename: Exercise1_4M.java (Ninth Edition Page 31 1.4 Modified; 10th Edition Page 30 1.4) Submit Filename: Population.java (Ninth Edition Page 32 1.11 Modified; 10th Edition Page 31 1.11)

Study/Read chapter 1 and take Canvas chapter 1 quiz.

Exercise1_4M.java Specifications. Output the integer numbers 1..10 with their square and cube (all numbers are integers). Fields are tab separated, each row ends in newline. First line is the string "A\tA^2\tA^3 ".

A A^2 A^3 1 1 1 2 4 8 3 9 27 ... A is up to and including 10 

Population.java - Minor Changes Read Description...

"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 20 years (starting at 2012 up to including 2031). Assume the current population for US is 312,032,486, for Saddleback College 2012 enrollment was about 26,000. Assume Each year will have exactly 365 days (ignore leap years). Hint: In Java, if two integers perform division, the result is an integer. The fraction part is truncated. For example, 5 / 4 is 1 ( not 1.25) and 10 / 4 is 2 ( not 2.5).". All numbers and calculations are in floating point double precision, when you print out populations typecast to int.

Your program should about three columns of data, first column is year, second is Saddleback population, third is US population. First Line is "Year\tSaddleback\tUS ". Once again fields are tab separated, each row is newline terminated. First two rows are...

Year Saddleback US 2012 26000 312032486 2013 26231 314812582 2014 26463 317592679 2015 26694 320372776

Assume population increase per year will remain constant, (no compounding); also assume that the initial population increase for SB, will be based on the US Census bureau data but will be scaled to reflect the 2012 population ratio of us to saddleback. For example calculate the population increase per year for the US, then multiple this increase by the ratio of the 2012 SB to US population. Print out all populations as int, but do all calculations using double. We will use System.out.println( ... "\t" + (int)usPopulation + ... ) or System.out.printf( "%d" , ..., (int)usPopulation). All programs must include a comment header detailing input/output specifications and logic used to convert input to output. For these two programs the input is internal to the program 1..10 in the first case, 1..20 in the second case.

Hints:

  • Except year, all variables are double, all calculations are double. Typecast double to int before printing.
  • Gain for population is a constant value calculated from birthrate, deatth rate and immigration rate.
  • Population increase for SB is just the US gain times 2012 ratio of SB population to US population. Note in reality Orange County actually has a slower birthrate than rest of US, but not for this assignment.

Nota Bene, these programs are review, but the second program will require some thought. If you have problems with the logic on population, then you may want to think about it before going to sleep, when you awake you may be able to write down the solution.

Consistency Note

  • All input is from standard in, System.in
  • All output is to standard output, System.out
  • Only exception is when we cover File I/O in later chapters
  • When we do calculations they are always double, unless specified otherwise.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!