0% found this document useful (0 votes)
3 views4 pages

Java Notes Unit 1 Part 04 Initial Programs

The document contains multiple Java classes demonstrating basic programming concepts. The classes include 'HelloWorld' which prints a message, 'Twice' which doubles a user-input number, 'Main' which checks if the number is a pass or fail, and 'DisplayDate' which shows the current date and time. Each class utilizes the Scanner for user input and showcases different functionalities.

Uploaded by

rameshtailor827
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Java Notes Unit 1 Part 04 Initial Programs

The document contains multiple Java classes demonstrating basic programming concepts. The classes include 'HelloWorld' which prints a message, 'Twice' which doubles a user-input number, 'Main' which checks if the number is a pass or fail, and 'DisplayDate' which shows the current date and time. Each class utilizes the Scanner for user input and showcases different functionalities.

Uploaded by

rameshtailor827
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

class HelloWorld{

public static void main(String args[]){


[Link]("CITM 2nd Aug 2023 - HelloWorld");
}
}
import [Link];
public class Twice{
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter any Number : " );
int number = [Link]();
[Link]("The double of "+ number + " is " + number*2);
}
}
import [Link];
public class Main
{
public static void main(String[] args) {
// [Link]("citm Welcome to Online IDE!! Happy Coding :)");

Scanner scanner = new Scanner([Link]);


[Link]("Enter any Number : " );
int number = [Link]();
[Link]("The double of "+ number + " is " + number*2);
if (number<50)
[Link]("Fail");
else
[Link]("PASS");
}
}
import [Link];
import [Link];

public class DisplayDate {


public static void main(String[] args) {
// Create a Date object representing the current date and time
Date currentDate = new Date();

// Create a SimpleDateFormat object to format the date


SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd
HH:mm:ss");

// Format the current date using the SimpleDateFormat


String formattedDate = [Link](currentDate);

// Display the formatted date


[Link]("Current date and time: " + formattedDate);
}
}

You might also like