Scanner System Programming Challenges
Scanner System Programming Challenges
1 Day 17 Criteria
import [Link].*;
Day 17 Criteria
Write a program to generate the below series: import [Link].*;
0,2,3,5,8,10,15,17,24,26,...
Input Format:
public class Main {
Input consists of a single integer that corresponds to n. public static void main(String[] args) {
Output Format:
The output consists of the terms in the series separated by a blank space. //fill your code here
Sample Input 1: Scanner sc=new Scanner([Link]);
11
Sample Output 1: int count=0, i=0, j=2, k=1, l=1;
0 2 3 5 8 10 15 17 24 26 35
Sample Input 2: for (int n=[Link](); count < n ;count ++){
20 int temp;
Sample Output 2:
0 2 3 5 8 10 15 17 24 26 35 37 48 50 63 65 80 82 99 101 if(count % 2==0)temp=count !=0?i=i+(k=k+2):i;
else temp = j= count !=1 ? j+(l=l+2):j;
[Link]("%d\t",temp);
}
2 Alphabet Patterns 4
Write a program to print the given pattern.
import [Link].*;
Input Format: public class Main {
Input consists of a single integer which corresponds to the number of rows..
Output Format:
Refer sample output.
Sample Input:
public static void main(String[] args) {
5 int i,j,n;
Sample Output:
E Scanner s = new Scanner([Link]);
ED
EDC
n= [Link]();
EDCB for(i=n;i>=1;i--)
EDCBA
{for(j=n;j>=i;j--)
{[Link]((char)(j+64));
}
[Link]();
}
}
}
3 Pattern 3
Write a program to print the given pattern.
import [Link].*;
Input Format:Input consists of a single integer. public class Main {
Output Format:
Refer sample outputs. There is a trailing space at the end of each line. public static void main(String[] args) {
Sample Input:
5
Scanner sc = new Scanner([Link]);
Sample Output: int n = [Link]();
54321
4321 for(int x=n;x>=1;x--)
321
21
{ for (int y=x;y>0;y--)
1 [Link](y + " ");
[Link]();
}
}
}
4 Day 13 Criteria
import [Link];
Write a program to generate the below series:
5,17,37,65,145, 197,….
public class Main {
}
6 GRADE import [Link];
Write a program to determine the grade of the student in a particular subject. Refer to the table given below for grade public class Main {
details. public static void main(String[] args)
Marks scored Grade { Scanner sc=new Scanner([Link]);
100 S
[90,100) A [Link]("Enter the marks");
[80,90) B double Marks=[Link]();
[70,80) C if(Marks==100)
[60,70) D { [Link]("The student obtained a S grade");
[50,60) E }
<50 F
The interval [a,b) includes all numbers greater than or equal to a and less than b.
else if(Marks<100&&Marks>=90)
Input and Output Format: { [Link]("The student obtained a A grade");
Input consists of a single integer that corresponds to the marks scored by the student. }
Print "Invalid Input" if it is not in the range 0 to 100. else if(Marks<90&&Marks>=80)
Refer sample input and output for formatting specifications. {
[All text in bold corresponds to input and the rest corresponds to output.]
[Link]("The student obtained a B grade");
Sample Input and Output 1:
Enter the marks }
85 else if(Marks<80&&Marks>=70)
The student obtained a B grade {
Sample Input and Output 2: [Link]("The student obtained a C grade");
Enter the marks 850 }
Invalid Input
else if(Marks<70&&Marks>=60)
{
[Link]("The student obtained a D grade");
}
else if(Marks<60&&Marks>=50)
{
[Link]("The student obtained a E grade");
}
else if(Marks<50&&Marks>=0)
{
[Link]("The student obtained a F grade");
}
else
{
[Link]("Invalid Input");
}
}
}
7
Pattern 1 import [Link].*;
Write a program to print the given pattern. public class Main {
Input Format:
Input consists of a single integer. public static void main(String[] args) {
Output Format: //fill your code here
Refer sample outputs. There is a trailing space at the end of each line.
Sample Input 1:
Scanner sc= new Scanner([Link]);
5 // [Link]("Num of rows");
Sample Output 1: int rows =[Link]();
12345
1234
123
//[Link]("pattern is");
12
1
//int n=5;
Sample Input 2: for(int i=rows;i>=1;i--){
3 for(int j=1;j<=i;j++){
Sample Output 2:
123 [Link](j+ "");
12
1 }
[Link]();
}
}
}
8
Palindromic Prize import [Link];
A customer in the Personalised Gift Store is awarded a prize when their bill number is a 3-digit palindrome. public class Main {
Write a program for identifying the prize winners.
Input Format: public static void main(String[] args) {
Input consists of a number that corresponds to the bill number.
Scanner scan = new Scanner([Link]);
Output Format: int billNo = [Link]();
The output consists of a string that is either 'yes' or 'no'. The output is 'yes' when the customer receives the prize and is 'no' if((billNo/100)==(billNo%10))
otherwise.
Sample Input 1: [Link]("yes");
565 else
Sample Output 1: [Link]("no");
yes [Link]();
Sample Input 2: }
568
Sample Output 2: }
no
Sample Input 3:
66
Sample Output 3:
no
10 import [Link];
Series-II
Write a program to generate the below series: public class Main {
4,32,128,256, ….n public static void main(String[] args) {
Input and Output Format: Scanner sc=new Scanner([Link]);
The first line is the input consists of a single integer that corresponds to n. int m=4;
The output consists of the series 4,32,128,…..n separated by a space. int multiple=8;
Sample Input 1: int n=[Link]();
4 for(int i=0;i<n;i++)
Sample Output 1: {[Link](m+" ");
4 32 128 256
m=m*multiple;
Sample Input 2:
2 multiple=multiple/2;
Sample Output 2: }
4 32 }
Sample Input 3: }
6
Sample Output 3:
4 32 128 256 256 0
11
Alphabet Pattern 1 import [Link].*;
public class Main {
Write a program to print the given pattern.
public static void main(String[] args) {
Input and Output Format: int i,j;
Input consists of a single integer that corresponds to the number of rows,n.
The output is the alphabet pattern for the given input,n. Scanner sc = new Scanner([Link]);
int n=[Link]();
Sample Input 1:
5
Sample Output 1: for(i=1;i<=n;i++)
A {
AB
ABC for(j=1;j<=i;j++)
ABCD {
ABCDE
[Link]((char)(j+64));
Sample Input 2: }
7
[Link]("");
Sample Output 2:
A }
AB }
ABC
ABCD
ABCDE }
ABCDEF
ABCDEFG
12
COUNTING
Write a program to count the vowels, consonants, digits, and white spaces in a string.
Input consists of a string. Assume the maximum length of the string is 200.
The characters in the string can contain both uppercase and lowercase.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to the input and the rest corresponds to output.]
13
Prime
Write a program to find whether a given number is prime or not.
Input Format:
Input consists of a single integer.
Output Format:
The output should display whether the input is “Prime” or “Not prime”.
Refer sample input and output for formatting specifications.
Sample Input 1:
13
Sample Output1:
Prime
Sample Input 2:
33
Sample Output2:
Not prime
16
Day 11 Criteria import [Link].*;
Write a program to generate the below series: public class Main {
24,60,120,210,…
Input Format:
Input consists of a single integer that corresponds to n. public static void main(String[] args) {
Output Format:
The output consists of the terms in the series separated by a blank space.
Scanner sc=new Scanner([Link]);
Sample Input 1: int n=[Link]();
5 for(int i=2;i<=n+1;i++)
Sample Output 1:
24 60 120 210 336 {
int j=i+1;
Sample Input 2:
10 int k=i+2;
Sample Output 2: [Link](i*j*k+ " ");
24 60 120 210 336 504 720 990 1320 1716
j=0;
k=0;
}
}
}
17 P3 – Number series import [Link];
Write a program to print the series ---- 1,3,6,10,15 ….. upto ‘n’ terms.
Input Format: public class Main {
Input consists of a single integer.
Output Format: public static void main(String[] args) {
Refer sample output for details.
Sample Input: Scanner sc = new Scanner([Link]);
6 int terms=[Link]();
Sample Output: int n=1;
1 3 6 10 15 21
int m=2;
[Link](n+" ");
for(int i=1;i<terms;i++)
{
n=n+m;
[Link](n+" ");
m++;
}
//Fill your code here
}
}
18
Alphabet Pattern 9 import [Link];
Write a program to print the given pattern.