Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Write a program which accepts days as integer and display total number of years,
months and days in it. Assume 1 Year = 365 Days
Program:
import java.util.Scanner;
}
Output:
2. Given 2 int values, return true if both the numbers are in the range 30..40 inclusive, or in
the range 40..50 inclusive
Program:
import java.util.Scanner;
}
Output:
3. Given 2 int values and Boolean flag (true/false), If flag is true: return true if exactly one
is negative and one is positive, false otherwise If flag is false: return true if either both are
positive or both are negative, false otherwise
Program:
import java.util.Scanner;
}
Output:
7. Accept two numbers and perform the following operations simultaneously 1. Print prime
numbers between them. 2. Print all numbers between them. 3. List all the multiples of two
between them
Program:
import java.util.Scanner;
}
System.out.println("NUmbers between them");
for(num=first;num<last;num++)
{
System.out.println(num);
}
System.out.println("Numbers multiple by 2");
for(num=first;num<last;num++)
{
if(num%2==0)
{
System.out.println(num);
}
}
}
public static void main(String[] args)
{
Operation t1=new Operation();
t1.start();
}
}
Output:
6. Crete an employee class with empno, first name, lastname, Date of Birth, Basic Salary,
Date of Joining, PAN Card and Aadhar card details. Include methods required to accept
and print the data. While printing the data along with the details, information about the
experience in the current company needs to be printed. Required Validations 1. Employee
must be of above 18 years 2. Date of joining should be above Date of Birth 3. Pan Card
should be of correct format 4. Aadhar card should be of 12 digits.
Program:
import java.util.Date;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
String cd1=first.substring(0,2);
String cd2=last.substring(2,4);
String str=cd1.concat(cd2);
System.out.println("code: "+str+"00"+cnt);
}
public void checkaadhar()
{
int num=aadhar.length();
if(num==12)
{
System.out.println("valid aadhar number");
}
else
{
System.out.println("invalid aadhar");
}
}
}
Output: