import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter first Date in dd/MM/yyyy format : ");
String firstDate = sc.next();
System.out.println("Enter second Date in dd/MM/yyyy format : ");
String secondDate = sc.next();
String[] fD = firstDate.split("/");
String[] sD = secondDate.split("/");
int day1 = Integer.parseInt(fD[0]);
int day2 = Integer.parseInt(sD[0]);
int month1 = Integer.parseInt(fD[1]);
int month2 = Integer.parseInt(sD[1]);
int year1 = Integer.parseInt(fD[2]);
int year2 = Integer.parseInt(sD[2]);
int days = day2 - day1;
int months = month2 - month1;
int years = year2 - year1;
if(days < 0)
{
days += 30;
months--;
}
if(months < 0)
{
months += 12;
years--;
}
System.out.println("Difference between two dates is : " + days + " days, " + months + " months, " + years + " years.");
}
}
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter first Date in dd/MM/yyyy format : ");
String firstDate = sc.next();
System.out.println("Enter second Date in dd/MM/yyyy format : ");
String secondDate = sc.next();
String[] fD = firstDate.split("/");
String[] sD = secondDate.split("/");
int day1 = Integer.parseInt(fD[0]);
int day2 = Integer.parseInt(sD[0]);
int month1 = Integer.parseInt(fD[1]);
int month2 = Integer.parseInt(sD[1]);
int year1 = Integer.parseInt(fD[2]);
int year2 = Integer.parseInt(sD[2]);
int days = day2 - day1;
int months = month2 - month1;
int years = year2 - year1;
if(days < 0)
{
days += 30;
months--;
}
if(months < 0)
{
months += 12;
years--;
}
System.out.println("Difference between two dates is : " + days + " days, " + months + " months, " + years + " years.");
}
}
👍1
//Write a java program to find palindrome in a given paragraph and create substring of the palindrome
public class PalindromeFinder {
static boolean isPalindrome(String str)
{
// Pointers pointing to the beginning
// and the end of the string
int i = 0, j = str.length() - 1;
// While there are characters toc compare
while (i < j) {
// If there is a mismatch
if (str.charAt(i) != str.charAt(j))
return false;
// Increment first pointer and
// decrement the other
i++;
j--;
}
// Given string is a palindrome
return true;
}
// Driver code
public static void main(String[] args)
{
String str = "This is a paragraph with a palindrome in it; racecar. malayalam print amam 12121 ";
String[] words = str.split(" ");
int len = words.length;
//String[] palindrome = new String[len];
for (int i = 0; i < len; i++) {
if (isPalindrome(words[i])) {
System.out.println("Palindrome found: " + words[i]);
//palindrome[i] = words[i];
}
}
/*
System.out.println("The palindrome in this sentence are:");
for (int i = 0; i < palindrome.length; i++) {
if (palindrome[i] != null) {
System.out.println(palindrome[i]);
}
}
*/
}
}
public class PalindromeFinder {
static boolean isPalindrome(String str)
{
// Pointers pointing to the beginning
// and the end of the string
int i = 0, j = str.length() - 1;
// While there are characters toc compare
while (i < j) {
// If there is a mismatch
if (str.charAt(i) != str.charAt(j))
return false;
// Increment first pointer and
// decrement the other
i++;
j--;
}
// Given string is a palindrome
return true;
}
// Driver code
public static void main(String[] args)
{
String str = "This is a paragraph with a palindrome in it; racecar. malayalam print amam 12121 ";
String[] words = str.split(" ");
int len = words.length;
//String[] palindrome = new String[len];
for (int i = 0; i < len; i++) {
if (isPalindrome(words[i])) {
System.out.println("Palindrome found: " + words[i]);
//palindrome[i] = words[i];
}
}
/*
System.out.println("The palindrome in this sentence are:");
for (int i = 0; i < palindrome.length; i++) {
if (palindrome[i] != null) {
System.out.println(palindrome[i]);
}
}
*/
}
}
👍1
You can now connect with us on linkedin we will soon list our connections for better opportunity
will update the video by late night today complete exception handling end to end
https://www.youtube.com/channel/UC-tiNJLxqiix-yswWo65cRw
Will share the video on this channel so you can visit and will not miss the recording too
Will share the video on this channel so you can visit and will not miss the recording too
Java Hyd Team
Next Sunday again we will be covering core java, advance java, Spring and spring boot , React-Js
Not conducted as one interview scheduled from trilogy innovations
It will be till 2pm so didn't started as full day packed after this will prepare video n upload for exception handling 😊
It will be till 2pm so didn't started as full day packed after this will prepare video n upload for exception handling 😊
till then solve this question If we list all the natural numbers below 10that are multiples of 3 or5 , we get 3,5,6 and9 . The sum of these multiples is .23
Find the sum of all the multiples of 3 or5 below .
Input Format
First line contains that denotes the number of test cases. This is followed by lines, each containing an integer, .
Constraints
Output Format
For each test case, print an integer that denotes the sum of all the multiples of 3 or 5 below N .
Find the sum of all the multiples of 3 or5 below .
Input Format
First line contains that denotes the number of test cases. This is followed by lines, each containing an integer, .
Constraints
Output Format
For each test case, print an integer that denotes the sum of all the multiples of 3 or 5 below N .