logic based java with star pattern_NIFSD03
logic based java with star pattern_NIFSD03
Pro1:-write program to read three int values and perform addition operation in java?
import java.util.Scanner;
obj.close();
}
Pro3:-Given an integer n , perform the following conditional actions ,if number is odd,print
bad number ,if number is even and in the range of 2 to 5 ,print good number,if number is
even and in the range of 6 to 20 ,print bad number .if number is even and greater then
20,print bad number?
contraint-> 1<=n<=100
import java.util.Scanner;
}
}
Pro4:- write program To check whether the given number is leap year or not ?
if we take any year it is said to be leap year if it follows the following conditions
1. if it is not a century year and divisible by 4
2. if it is a century year and divisible by 400
import java.util.Scanner;
Pro5:- The e-commerce company Bookshelf wishes to analyse its monthly sales data
between minimum range 30 to max range 100. The company has categorized these book
sales into four groups depending on the number of sales with the help of these groups the
company will know which stock they should increase or decrease in their inventory for the
next month.
sales range groups
30-50 ------------------> D
51-60 ------------------> C
61-80 ------------------> B
81-100 -----------------> A
constraint---> 30<=saleCount<=100
import java.util.Scanner;
}
Pro8:- write a program to calculate sum of digits present in the given
number.
import java.util.Scanner;
}
}
import java.util.Scanner;
Pro17:- Given a decimal number, write a program to convert the number into a binary
form.
import java.util.Scanner;
Implement a program to accept a two digit number and check whether it is a special two
digit number or not.
input -----> a two digit number
constraint-> 10<=n<=99
output ----> special two digit number or not
ex:- 59 ====> (5+9)+(5*9) =14+45=59
import java.util.Scanner;
import java.util.Scanner;
if(s.charAt(i)=='a'||s.charAt(i)=='e'||s.charAt(i)=='i'||s.charAt(i)=='o'||s.charAt(i)==
'u')
c++;
}
System.out.println("this word contains "+c+" vowels");
}
}
Pro34:-write a program that takes a word and return true if the
word has two consecutive identical letters.
public class Test {
if(s.charAt(i)=='a'||s.charAt(i)=='e'||s.charAt(i)=='i'||s.charAt(i)=='o'||s.charAt(i)==
'u')
{
System.out.println(i);
break;
}
}
}
}
Pro38:-write a program that find longest word in a sentence .if two
or more words are found ,return the first longest word.
import java.util.StringTokenizer;
if(s.charAt(i)=='a'||s.charAt(i)=='e'||s.charAt(i)=='i'||s.charAt(i)=='o'||s.charAt(i)==
'u')
continue;
else
c++;
}
System.out.println(c);
}
}
Pro44:-write a program to read an array elements and prints sum of all its
elements.
}
Pro56:-write a program to update an element in the given array.
public class Test {
}
Pro59:-write a program to find the number of duplicate elements present in the
given array.
public class Test {
}
Pro60:-write a program to find the sum of two arrays and display the result array
public class Test {
}
Pro61:-write a program to print reverse of each element in an
array.
public class Test {
static int rev(int n)
{
int r=0,d;
while(n!=0)
{
d=n%10;
r=r*10+d;
n=n/10;
}
return r;
}
}
Pro62:-write a program to sort only first half of the arrays
public class Test {
}
Pro63:-write a program to find the difference between two arrays
public class Test {
for(i=0;i<n;i++)
System.out.print((a[i]-b[i])+" ");
}
Pro64:-write a program to eliminates odd numbers within array.
public class Test {
}
Pro65:-write a program to check whether an array is paliandrome or
not.
public class Test {
}
}
Pro67:-write a program to find sum of diagonal elements in matrix
public class Test {
}
}
}
}
Pro67:-
}
}
Pro68:-
Pro69:-
Pro70:
Pro71:-
Pro72:-
public class Test {
Pro73:-
Pro74:-
public class Test {
Pro78:-
Pro79:-
public class Test {
Pro 81:-
public class Test {
Pro82:-
Pro:84
Pro85:-