Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How old will I be in... ? Topics This assignment will give you practice with interactive programs, if/else statements and methods that return values. Instructions

How old will I be in... ?

Topics

This assignment will give you practice with interactive programs, if/else statements and methods that return values.

Instructions

Your program will prompt the user for information about their birthdate, and then ask for an age. Your program will then calculate the date at which the user will be that age, and print it out for the user.

User Prompts

The program asks the user for three integer values: the year, month, and date of the birthdate. For a hypothetical birthdate of August 24, 1999, the user enters 1999 and then 08 and then 24. You can assume that the user enters valid dates for the birthdate.

The program then asks the user for a decimal value indicating the age (in years) that they want used in computation. This should be read in and stored in a variable of appropriate type.

Computing the Date

At this point your program has a birthdate (represented by three numbers) and an age (represented by a single decimal number). The program should compute on what day the user will be that age. For example, given the birthdate above, and an age of 31.4, the program reports back that the user is that age on January 17, 2031. You may ignore leap days/years.

  • You will probably have to compute from a date (08-24-1999) to a number of days (since 00-00-00) and back again
  • You will probably have to compute how many days of the year have passed when you are in a month (for example, if you're in March, at least 59 days have passed in that year)
  • You will probably have to compute how many months have passed, when you are a certain number of days into the year (for example if you are 36 days into the year, that is February 5th)
  • You may choose a rounding method to get from a decimal number of years to an integer for the date, but you must include a comment explaining your rationale

Sample Output

Your output must match the format provided.

User input is displayed between __ double underscores __ so that you can tell what output is generated by the program and what is input by the user. Your program output will not include these underscores.

 ----jGRASP exec: java BirthdateCalc Enter the year you were born (YYYY): __1999__ Enter the month you were born (MM): __08__ Enter the date you were born (DD): __24__ I will compute the date when you will be...how many years old? __21__ 21.000000 years is 7665 days On 8-24-2020 you will be 21.000000 ----jGRASP: operation complete. ----jGRASP exec: java BirthdateCalc Enter the year you were born (YYYY): __1999__ Enter the month you were born (MM): __08__ Enter the date you were born (DD): __24__ I will compute the date when you will be...how many years old? __31.4__ 31.400000 years is 11461 days On 1-17-2031 you will be 31.400000 ----jGRASP: operation complete.

Other Notes

  • You should use static methods to eliminate redundant code and to break the problem up into logical subtasks. This includes making methods that return data and methods that take data as a parameter.
  • Your main method should be short so that a person can easily see the overall structure of the program.
  • You are to introduce at least five static methods other than main to break this problem up into smaller subtasks and you should make sure that no single method is doing too much work.
  • In this program, none of your methods should have more than 25 lines of code in the body of the method (not counting blank lines or lines with just curly braces on them). The 25-line limitation is a special requirement for this assignment to force you to practice breaking up a program into methods.
  • Be sure to once again include a short comment at the beginning of your program as well as a short comment for each method describing what it does.
  • You do not have to perform any error checking. We will assume that the user enters numbers that are in the appropriate range.
  • You should avoid "chaining" long sequences of method calls together without returning to main.
  • Note that because this program involves both integer data and decimal data, you need to use appropriate type declarations (type int and calls on nextInt for integer data, type double and calls on nextDouble for real-valued data).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

LO29.1 Describe the business cycle and its primary phases.

Answered: 1 week ago

Question

What category of visualizations did you produce in this lab?

Answered: 1 week ago