Write an application starting with ProjectTemplate. Name the class AgeCalcApp. The app needs to prompt the user for the following information:Enter person's nameEnter the year of last birthdayEnter the year of birthWhen the Run button is clicked, the display should read[name] is [age] years old (where name is the person's name and age is the person's age)

Question
Asked Oct 2, 2019

Write an application starting with ProjectTemplate. Name the class AgeCalcApp. The app needs to prompt the user for the following information:
Enter person's name
Enter the year of last birthday
Enter the year of birth
When the Run button is clicked, the display should read
[name] is [age] years old (where name is the person's name and age is the person's age)

check_circleExpert Solution
Step 1

To write an application name ProjectTemplate with the class name AgeCalcApp. This application prompts the user to enter the person’s name, last birthday year and the year of birth and calculating the age of user by subtracting the last birthday year from the year of birth. And displaying the output as:

[name] is [age] years old (where name is the person's name and age is the person's age)

Step 2

Providing the program code in java as here, no programming language is specified,

Program code:

import java.util.Scanner;

public class AgeCalcApp

{

    //Main method

public static void main (String[] args)

    {

        //displaying message to user to enter name

   System.out.println("Enter the person name: ");

   //taking input of name

        Scanner sc=new Scanner(System.in);

        String name=sc.nextLine();

        System.out.println("Enter the last birthday year: ");

                //taking input of last birthday year

        Scanner object=new Scanner(System.in);

        int lastyear=sc.nextInt();

       System.out.println("Enter your birth year: ");

                //taking input of birth year

               int birthyear=sc.nextInt();

               //displaying output to user

    System.out.println( ""+name+" is "+(lastyear-birthyear)+ " years old");

    }

}

Step 3

Output of the above ...

Enter the person name:
jack
Enter the last birthday year:
2018
Enter your birth year:
1997
jack is 21 years old
help_outline

Image Transcriptionclose

Enter the person name: jack Enter the last birthday year: 2018 Enter your birth year: 1997 jack is 21 years old

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour*

See Solution
*Response times may vary by subject and question
Tagged in

Engineering

Computer Science

Java

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: In C++ Ask the user for three friends names, store the names in an array.  Output the array to a fil...

A: Program://include the required header files#include <iostream>#include<fstream>#include ...

question_answer

Q: in Python using IDLE   Now write another program that reads her inventory file, displays all data fo...

A: A Python program to display the data for each item in an inventory is given below;Program:#Print the...

question_answer

Q: Provide a situation that encompasses Integrity in the CIA triad

A: DefinitionIntegrity plays the foremost role in CIA triad. It is designed to secure the data from an ...

question_answer

Q: Write a python code of a function that takes in four points in a counterclockwise order, a, b, c, d ...

A: Program Instructions:Create a function isConvex() and pass the four points as arguments.Save the par...

question_answer

Q: For problem 10RQ for Business Informaiton Systems book by Paige Baltzan, the question asked what is ...

A: The terms Collective intelligence, Knowledge management and Crowdsourcing are related to each other ...

question_answer

Q: Hello, I am using the Intro to Java programmming and data structures by Y. Daniel Liang. Our profess...

A: A java program to check the user’s input is a factor of random number generated is given below;Progr...

question_answer

Q: please solve this in python  //////////////// ////////////////   ////////////////   ////////////////

A: Program Instructions:Create three functions namely top(), body() and word() to print the different p...

question_answer

Q: PLEASE EXPLAIN ALL STEPS: simplify the boolean equations: xz + (xy + ~z) ~xyz + yz + x~y

A: 1)xz + (xy + ~z)For simplifying the Boolean expression, use Karnaugh Map and follow the below steps-...

question_answer

Q: in eclipse

A: In operator overloading, the type of arguments defines which function will be called at the run-time...