Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please Complete the following 4 Exercises which account for Chapter 1 Activities

ID: 3843766 • Letter: P

Question

Please Complete the following 4 Exercises which account for Chapter 1 Activities

1.10 (Average speed in miles) Assume a runner runs 14 kilometers in 45 minutes and 30 seconds. Write a program that displays the average speed in miles per hour. (Note that 1 mile is 1.6 kilometers.) "1.11 (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 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.

Explanation / Answer

Hi, I hvae implemented 2 questions. Please repost other questions in separate post.

1.10)

public class AverageSpeed {

  

   public static void main(String[] args) {

      

      

       double distance = 14/1.6; // in miles

      

       double time = (45*60)+30; // in seconds

      

       double hour = time/3600.0; // number of hours

      

       double speed = distance/hour; // miles/hours

      

       System.out.println("Average speed : "+speed+" miles/hour");

   }

}

/*

Sample run:

Average speed : 11.538461538461538 miles/hour

*/

1.4)

public class Exercise01_04 {

  

   public static void main(String[] args) {

      

       System.out.println("a a^2 a^3");

       for(int i=1; i<=4; i++){

           System.out.println(i+" "+(i*i)+" "+(i*i*i));

       }

   }

}

/*

Sample run:

a   a^2   a^3

1   1   1

2   4   8

3   9   27

4   16   64

*/