cover picture cover picture


Homework 3

CMP 167: Programming Methods I
Lehman College, City University of New York
Spring 2016


This Homework Is Due By 11:59 PM on Wednesday March 2, 2016

In your textbook, this homework problem is in section 2.23 Homework 3-1.

Nestlé sells a brand of water named Ice Mountain. The water that Nestlé uses for Ice Mountain is pumped out a public underground aquifer in West Michigan. Nestlé pumps water from the aquifer at the rate of 400 Gallons per minute. Nestlé pays nothing for the water they pump, but they bottle it in 16.9 Oz bottles.

Assuming that Nestlé sells each bottle for $1.25, write a program that computes the following:

  1. The amount of water that Nestlé pumps out of the aquifer each day.
  2. The amount of water that Nestlé pumps out of the aquifer each week.
  3. The amount of water that Nestlé pumps out of the aquifer each year.
  4. The number of bottles of Ice Mountain that Nestlé sells each day.
  5. The number of bottles of Ice Mountain that Nestlé sells each week.
  6. The number of bottles of Ice Mountain that Nestlé sells each year.
  7. The amount of money that Nestlé makes each day.
  8. The amount of money that Nestlé makes each week.
  9. The amount of money that Nestlé makes each year.

You may assume that a year has 365 days.

Your output must be of the format:

    Gallons pumped per day  = gallonsPerDay
    Gallons pumped per week = gallonsPerWeek
    Gallons pumped per year = gallonsPerYear

    Bottles produced per day  = bottlesPerDay
    Bottles produced per week = bottlesPerWeek
    Bottles produced per year = bottlesPerYear

    Dollars made per day  = dollarsMadePerDay   
    Dollars made per week = dollarsMadePerWeek   
    Dollars made per year = dollarsMadePerYear   
  

Please note that your class should be named IceMountain.

In your textbook, this homework problem is in section 3.15 Homework 3-2.

Write a program that computes the fare on Copenhagen Transit given two inputs from the user:

Your prompts to the user must be:

    Enter zone number :
    Enter adult or child :
  

The fare on Copenhagen Transit is specified as follows:

Your output must be of the format:

    The fare for adultOrChild to zone number zoneNumber is fare. 
  

Please note that your class should be named CopenhagenTransit.

In your textbook, this homework problem is in section 3.16 Homework 3-3.

Write a program that asks the user for their age in days. The program will compute the person's age in years and then prints one of the following messages:

  1. If the user is 1 year old or younger, print: "You are an infant"
  2. If the user is over 1 year old and 3 years old or younger, print: "You are a toddler"
  3. If the user is over 3 years old and 12 years old or younger, print: "You are a child"
  4. If the user is over 12 years old and 19 years old or younger, print: "You are a teenager"
  5. If the user is over 19 years old and 21 years old or younger, print: "You are a young adult"
  6. If the user is over 21 years old and 50 years old or younger, print: "You are an adult"
  7. If the user is over 50 years old but 65 years old or younger, print: "You are middle aged"
  8. If the user is over 65 years, print: "You are a senior citizen"

For example:

    If the user entered: 350, your program would output: You are an infant
    If the user entered: 800, your program would output: You are a toddler
    If the user entered, 1825, your program would output: You are a child
    If the user entered, 5475, your program would output: You are a teenager
    If the user entered, 7300, your program would output: You are a young adult
    If the user entered, 10950, your program would output: You are an adult
    If the user entered, 23725, your program would output: You are middle aged
    If the user entered, 25550, your program would output: You are a senior citizen
  

Your prompt to the user to enter the number of days must be:

    Enter your age in number of days:
  

Please note that your class should be named AgeLabel.

Please submit the completed assignment in the corresponding section(s) in your textbook Lehman College City University of New York CMP 167 Spring 2016: Programming in Java. No other forms of submission will be accepted.