1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ivolga24 [154]
3 years ago
14

In this lab, you declare and initialize variables in a Java program. The program file named NewAge.java, calculates your age in

the year 2050.
Computers and Technology
1 answer:
Romashka-Z-Leto [24]3 years ago
3 0

Answer:

import java.util.Calendar;

import java.util.Date;

import java.util.Scanner;

public class Main {

   public static void main(String[] args) {

       System.out.print("Insert Date of Birth: ");

       String[] dateofbirth = new String[3];

       Scanner s1 = new Scanner(System.in);

       int a=0;

       while (a<=2) {

           dateofbirth[a] = s1.next();

           a++;

       }

       System.out.print("Insert future date: ");

       String[] futuredate = new String[3];

       Scanner t1 = new Scanner(System.in);

       a=0;

       while (a<=2) {

           futuredate[a] = t1.next();

           a++;

       }

       Calendar cal1 = Calendar.getInstance();

       cal1.set(Calendar.DAY_OF_MONTH, Integer.parseInt(dateofbirth[0]));

       cal1.set(Calendar.MONTH, Integer.parseInt(dateofbirth[1]));

       cal1.set(Calendar.YEAR, Integer.parseInt(dateofbirth[2]));

       Date first_Date = cal1.getTime();

       cal1.set(Calendar.DAY_OF_MONTH, Integer.parseInt(futuredate[0]));

       cal1.set(Calendar.MONTH, Integer.parseInt(futuredate[1]));

       cal1.set(Calendar.YEAR, Integer.parseInt(futuredate[2]));

       Date second_Date = cal1.getTime();

       long diff = second_Date.getTime() - first_Date.getTime();

       System.out.println ("Age in Days: " + diff / 1000 / 60 / 60 / 24/365);

   }

}

Explanation:

Please check the answer section. In this program we have created two strings, and inpit two dates through them. And then we parse the string items, and store the days, months and years in the calander instance, and we create two such instance. And finally, we find the differene and print the age in days.

You might be interested in
Answer for 3 and 4 please
Nata [24]

Answer:

3. D: px

4. B: web page

Explanation:

All font sizes are measured in px unless specified otherwise (in em's for example).

The correct answer is a web page because itself is a unique file that displays multimedia components.

3 0
3 years ago
Read 2 more answers
The compiler determines the parameterized type in a function template ___________.
KonstantinChe [14]

Answer:

 All of the given options are incorrect, as the parameterized type in the function template are determined by the implicitly way by compiler.

In the function template, the parameter type is basically determined by the polymorphic process as the polymorphic behavior are mainly determine by the programmer but the parameterized type in the given function template are mainly determine by the compiler not by the type of the name in the function template.

Therefore, implicitly way for determining the parameterized type in the given function template.

8 0
3 years ago
When employees are hired, they agree to only use cell phones during breaks. How would you classify this?
Rasek [7]
Ddddddddddddddddddddddddddddddddddddddddd
7 0
3 years ago
Read 2 more answers
The large structure that supports a spacecraft prior to launch is called the
OlgaM077 [116]
Launch tower

Hope that helps
         

7 0
3 years ago
What color object would reflect more light?<br> O Red<br> O Black<br> O Blue<br> o White
Deffense [45]

Answer:

White

Explanation:

Red absorbs all light except red light, which it reflects

Black absorbs all light

Blue absorbs all light except blue light, which it reflects

White reflects all light because it has all colors except black.

Hope you do well!

4 0
3 years ago
Other questions:
  • 13) What are the benefits and detriments of each of the following? Consider both the systems and the programmers’ levels. a. Sym
    14·1 answer
  • A computer programme that tells the computer how to perform particular tasks
    8·1 answer
  • A variable of the data type arrays is storing 10 quantities. What is true about these quantities?
    10·1 answer
  • Given the following code fragment and the input value of 4.0, what output is generated?
    8·1 answer
  • Which of the following is the most significant outcome of the formation of the SMPTE?
    6·2 answers
  • Irena sends unwanted e-mails to another girl in her class, but she is reported to the principal. Irena stops sending the e-mails
    12·2 answers
  • What line of code makes the character pointer studentPointer point to the character variable userStudent?char userStudent = 'S';
    5·1 answer
  • Consider we have n pointers that need to be swizzled, and swizzling one point will take time t on average. Suppose that if we sw
    11·1 answer
  • What Microsoft feature enables you to represent text as colorful visuals
    12·1 answer
  • Which wireless technology will John use to provide wide-range cellular service that focuses on indoor coverage, low cost, long b
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!