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
If byte stuffing is used to transmit Data, what is the byte sequence of the frame (including framing characters)? Format answer
Lerok [7]

Answer:

Correct Answers: 01h 79h 1Bh 78h 78h 1Bh 7Ah 04

Explanation:

Solution is attached below

4 0
3 years ago
Given an alphanumeric string made up of digits and lower case ASCII characters only, find the sum of all the digit characters in
lara31 [8.8K]

Answer:

C++.

Explanation:

#include <iostream>

#include <string>

using namespace std;

////////////////////////////////////////////////////////////////////////////

int sumDigits(string alphanumeric) {

   if (alphanumeric.length() == 1) {

       if ((int(alphanumeric[0]) >= 48) && (int(alphanumeric[0]) <= 57)) {

           cout<<int(alphanumeric[0]) - 48<<endl;

           return (int(alphanumeric[0]) - 48);

       }

       else

           return 0;

   }

   else {

       if ((int(alphanumeric[0]) >= 48) && (int(alphanumeric[0]) <= 57)) {

           cout<<int(alphanumeric[0]) - 48<<endl;

           return int(alphanumeric[0]) - 48 + sumDigits(alphanumeric.substr(1, alphanumeric.length()-1));

       }

       else

           return 0 + sumDigits(alphanumeric.substr(1, alphanumeric.length()-1));

   }

}

////////////////////////////////////////////////////////////////////////////

int main() {

   cout<<"Sum: "<<sumDigits("ab1c2d3e54");

   return 0;

}

3 0
3 years ago
The best defenses against covert channels include IDS and intrusion prevention system (IPS) and thoroughly watching all aspects
ddd [48]

Answer:

The statement is True

Explanation:

When talking about computer security, we can define covert channels as an attack on a system capable of creating a loophole for information objects transfer between various processes that would normally not allow communication under the computer security policy. Hence, the best defenses system against this kind of attack is via Intrusion Defense System and Intrusion Prevention System and relentlessly "watching all aspects of an IT infrastructure for aberrant or abnormal events of any type."

7 0
3 years ago
PYTHON PY
Kay [80]

Answer:

Explanation:

start with what you know

4 0
2 years ago
Please help
guapka [62]

From: Tom Pearson, Manager, District Five

Regarding: New Incoming Manager, Geraldine Hines

Dear Comstock Staff: Beginning March 15, 2018, you will have a new District Five Regional Manager. After 35 years of continuous service, I am leaving all of you to pursue an exciting future.

It has been my pleasure to train my successor, Geraldine Hines, this past year. Geraldine has demonstrated that she shares the company vision to be the employer of choice here in the Valley of the Sun. I am confident that she will lead all of you into the stratosphere as we merge our call centers and expand our donor site availability.

Please give Geraldine the same level of excellence you have given to me, to our staff and to our donors.

Sincerely.

Tom Pearson, Outgoing Manager, District Five

3 0
3 years ago
Other questions:
  • A person can receive an electric shock by
    15·2 answers
  • Are all tps dashboards
    15·1 answer
  • What is interest? How does interest affect credit card purchases?
    11·1 answer
  • How to fix this.. facing this problem to upload logo
    12·1 answer
  • Rachel wants to copy eight rows of data from one spreadsheet to another. She opens the spreadsheet, highlights the appropriate d
    15·2 answers
  • Write a program named as reverse.c that reads a message, then prints the reversal of the message. The output of the program shou
    7·1 answer
  • Listed three functions tht are ysed in a spreadsheet​
    10·1 answer
  • How to add links in HTML? ​
    8·1 answer
  • A web site that contains large numbers of misspelled words and grammatical errors fails which of these general criteria?
    9·1 answer
  • Utility software is used to maintain a computer.(yes or no)​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!