Académique Documents
Professionnel Documents
Culture Documents
1.
Write a java program for listing out all the even numbers between two
numbers.
import java.io.*;
import java.util.*;
No.
1
2
3
class b{
public static void main(String[] args) {
System.out.println("Enter a");
Scanner as=new Scanner(System.in);
int a=as.nextInt();
System.out.println("Enter b");
Scanner az=new Scanner(System.in);
int b=az.nextInt();
for(int i=a;i<=b;i++)
{
if (i%2==0){
System.out.println("Even no."+i); }}}}
Prime Number Between 2 Numbers
Expected
Test Case
Input
Output
Integer
6
2
4
Integer
2
11
2 4 6 8 10
Integer
6
6
Nothing
alphabets
Error
Integer
Long Int
Negative
Integer
Negative
Integer
Float
Float
a
222222
22
Error
a
222222
22
Numbers
-20
-8
Null
-6
1.2
-1.2
-6
4.2
-4.2
Null
Null
NULL
7
8
9
10
2.
Observed
Output
4
2 4 6 8 10
nothing
Random
numbers
Random
numbers
Valid/Inval
id
Valid
Valid
Valid
Error
negative
numbers
negative
numbers
2
-2 -4
Invalid
import java.io.*;
import java.util.*;
class c{
public static void main(String[] args) {
System.out.println("Enter a");
Scanner as=new Scanner(System.in);
int a=as.nextInt();
int m;
Invalid
Invalid
Invalid
Invalid
Invalid
Invalid
for(int i=1;i<11;i++)
{
m=a*i;
System.out.println("output is"+m);}}}
No.
Test Case
Integer
2 to 20
2 to 20
Valid
Integer
4 to 40
4 to 40
Valid
Integer
10.4
Error
Error
Valid
Integer
10
Table
Table
Valid
Alphabets
Error
Mismatch Exp
Invalid
Negative Integer
Table
Table
Valid
Long Int
-10
222222222
2
Table
Mismatch Exp
Invalid
Float
2.2
246
Invalid
Float
-2.2
Table
Error
Invalid
10
Zero
0000
0000
Valid
*
*
Valid/Invali
d
*
*
*
*
*
*
*
*
*
*
import java.util.Scanner;
class Dimond
{
public static void main(String[] args)
{int n, c, k, space = 1;
Scanner s=new Scanner(System.in);
System.out.println("Enter number of rows: ");
n=s.nextInt();
space = n - 1;
for (k = 1; k<=n; k++)
{
for (c = 1; c<=space; c++)
System.out.print(" ");
space--;
for (c = 1; c<= 2*k-1; c++)
System.out.print("*");
System.out.print("\n");
}
space = 1;
for (k = 1; k<= n - 1; k++)
{
for (c = 1; c<= space; c++)
System.out.print(" ");
space++;
for (c = 1 ; c<= 2*(n-k)-1; c++)
System.out.print("*");
System.out.println("");
}
}}
Diamond Pattern
No.
Test Case
Input
Expected Output
Observed Output
Valid/Invalid
Integer
7 rows
7 rows
Valid
Integer
9 rows
9 rows
Valid
Integer
1000000
Diamond
Infinite loop
Invalid
Integer
10000000
Diamond
Infinite loop
Invalid
alphabets
Error
Mismatch Exp
Invalid
Negative Integer
-10
Error
Invalidv input
Invalid
Long Int
222222222
Diamond
Mismatch Exp
Invalid
Float
5.2
Diamond
Error
Invalid
Float
-5.2
Diamond
Error
Invalid
10
Zero
Valid
Lab 2
Design Test cases for the given A.T.M System.
No
1
2
3
4
5
6
7
8
Test Case
Card Inserted
Correctly
Card Inserted
incorrectly
Correct Pin entered
Incorrect Pin entered
Cash <= Balance
Cash >= Balance
Cash with Receipt
<= balance
Cash with Receipt
>= balance
9 Balance on Screen
10 Printed balance
Balance check after
11 withdrawal
12 Pin change
13 Mini statement
Actual Output
Expected Output
Valid/Invalid
Card Accepted
Card accepted
Valid
Not Responding
Accept Pin
Not accepting
Withdrawal
Withdrawal
Withdrawal with
receipt
Withdrawal with
receipt
Show balance on
screen
Print Balance on
receipt
Balance not
changed
Pin Not Changed
Print mini
statement
Card rejection
Accept Pin
Reject Pin
Withdrawal
Error
Invalid
Valid
Invalid
Valid
Invalid
Valid
Error
Invalid
Valid
Valid
Valid
Invalid
Invalid