Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

15.13 Programming Assignment #12 Various websites like Wikipedia or IMDB list not just a person's birthdate but also the person's current age. Given a

image

15.13 Programming Assignment #12 Various websites like Wikipedia or IMDB list not just a person's birthdate but also the person's current age. Given a person's birthdate and current date, output the person's age in years. Write a method that, given a person's birthdate and current date, returns the person's age in years. The custom is to round down. If the input is 71 2000 2 15 2015, the output is 14 (because the person hasn't yet reached their 15th birthday). A person less than 1 has age 0. Hints: Start by computing currAge just as the difference in years. Then, use an if-else statement to determine whether to decrement currAge. One reason to decrement is if the current month is less than the birth month (no birthday yet this year). Another reason to decrement is if the current month equals the birth month, but the current day is less than the birth day. 354538.2438654.qx3zqy7 LAB ACTIVITY 15.13.1: Programming Assignment #12 LabProgram.java 0/5 Load default template... 4 5 6 3 public class LabProgram { public static int getAge (int birthMonth, int birthDay, int birthYear, int currMonth, int currDay, int currYear) /* Type your code here. */ 7 8 } 9 10 11 12 13 public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int birthMonth, birthDay, birthYear; int currMonth, currDay, currYear; 14 15 birth Month scnr.nextInt(); birthDay 16 currMonth scnr.nextInt(); currDay = 17 18 = = scnr.nextInt(); birth Year scnr.nextInt(); scnr.nextInt(); currYear = scnr.nextInt(); System.out.println(getAge (birth Month, birthDay, birthYear, currMonth, currDay, currYear)); 19

Step by Step Solution

3.35 Rating (161 Votes )

There are 3 Steps involved in it

Step: 1

Steps Step 1 of 1 C program wih the function 1 include 2 using namespace std 3 4 int GetAge int birt... 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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions