Answer to Question #139475 in Java | JSP | JSF for richelle ustari

Question #139475
Write a program that asks a user for their birth year encoded as two digits (like "62")
and for the current year, also encoded as two digits (like "99"). The program is to
correctly write out the users age in years.
1
Expert's answer
2020-10-20T16:09:27-0400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the birth year");
        int birth = in.nextInt();
        System.out.println("Enter the current year:");
        int current = in.nextInt();
        System.out.println("The age is: " + (current - birth));
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS