Question
Write comments in every single line in java package com.company; import java.lang.*; import java.io.FileWriter; import java.util.*; import java.time.format.DateTimeFormatter; import java.time.LocalDateTime; import java.lang.*; import java.io.BufferedReader; import
Write comments in every single line in java
package com.company;
import java.lang.*;
import java.io.FileWriter;
import java.util.*;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
import java.lang.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.FileWriter;
import java.util.*;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter Name");
String name=sc.nextLine();
System.out.println("Enter ID");
String id=sc.nextLine();
try
{
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
FileWriter fw=new FileWriter("D:testout.txt");
fw.write(name+" "+id+" "+dtf.format(now));
fw.close();
System.out.println("Registered successfully");
}
catch(Exception e){System.out.println(e);}
System.out.println("Success...");
System.out.println("");
System.out.println("Enter ID To see your vaccine dose data and time ");
BufferedReader br;
String line = "";
int found=0;
String st=sc.nextLine();
try {
br = new BufferedReader(new FileReader("D:testout.txt"));
try {
while((line = br.readLine()) != null)
{
String[] words = line.split(" ");
for (String word : words) {
if (word.equals(st)) {
found=1;
break;
}
}
}
br.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(found==1)
{
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
LocalDateTime tom = now.plusDays(7);
LocalDateTime tom1 = tom.plusDays(27);
System.out.println("First Dose is "+dtf.format(tom));
System.out.println("Second Dose is "+dtf.format(tom1));
}
else
System.out.println("Candidate have not registered");
}
}
Step by Step Solution
3.44 Rating (144 Votes )
There are 3 Steps involved in it
Step: 1
package comcompany import javalang import javaioFileWriter import javautil import javatimeformatDateTimeFormatter import javatimeLocalDateTime import ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Document Format ( 2 attachments)
636b5a6fe4d37_243540.pdf
180 KBs PDF File
636b5a6fe4d37_243540.docx
120 KBs Word File
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started