INSTRUCTIONS TO WRITE THE RECORD
Write the program on the right side and variable description table on
the left side.
Follow the same format.
Start the next program on a new page.
Do the variable description table by yourself from pgm-2. One has
been done for you in the first program.
Program: 1
JAVA PROGRAM TO DO ELECTRICITY BILL CALCULATION
AIM:
An electricity board charges the following rates to domestic users to discourage
large consumption of energy :
For the first 100 units − 40 P per unit
Next 200 units – 60 P per unit
Beyond 300 units − 90 P per unit
Add Rs.50 as service charge for all the consumers.
PROGRAM CODING :
import java.util.*;
class deci1
static void main()
int units;
double charge;
Scanner s=new Scanner(System.in);
System.out.println("enter the no. of units consumed");
units=s.nextInt();
if(units<=100)
charge=units*0.40+50;
else if(units>=101 && units<=300)
charge=100*0.40+(units-100)*0.60+50;
else
charge=100*0.40+200*0.60+(units-300)*0.90+50;
System.out.println("charge to be paid by the customer is"+charge);
}}
INPUT/OUTPUT:
enter the no. of units consumed
250
charge to be paid by the customer is 130
RESULT:
Thus the program is executed successfully.
Variable Description Table:
s.no Variable Datatype Description
1 Units int No of units
2 Charge double Amount to be paid
Program: 2
CALCULATE AREA OF DIFFERENT SHAPES
AIM:
A Java program to implement menu driven calculator to find the area of square,
rectangle, circle.
PROGRAM CODING :
import java.util.*;
class deci2
public static void main()
int ch;
double area,r,l,b,side;
Scanner s=new Scanner(System.in);
System.out.println("enter your choice/n 1.area of square/n2.area of
rectangle/n3.area of circle");
ch=s.nextInt();
switch(ch)
case 1: System.out.println("enter side");
side=s.nextDouble();
area=side*side;
System.out.println("area of square"+area);
break;
case 2: System.out.println("enter length & breadth");
l=s.nextDouble();
b=s.nextDouble();
area=l*b;
System.out.println("area of rectangle"+area);
break;
case 3: System.out.println("enter radius");
r=s.nextDouble();
area=3.14*r*r;
System.out.println("area of circle"+area);
break;
default:System.out.println("enter a valid choice");
}}
INPUT/OUTPUT:
enter your choice
1.area of square
2.area of rectangle
3.area of circle
enter length & breadth 5 7
area of rectangle 35
RESULT:
Thus the program is executed successfully.
Program: 3
CHECKING OF A NUMBERR IS PALINDROME NUBER
AIM:
Write a java program to check a number is a palindrome number or not.
PROGRAM CODING:
import java.util.*;
class loop1
public static void main()
int i,n,rev=0;
Scanner s=new Scanner(System.in);
System.out.println("program checks a number is palindrome or not");
System.out.println("Enter n");
n=s.nextInt();
int n1=n;
while(n>0)
int d=n%10;
rev=rev*10+d;
n=n/10;
if(rev==n1)
System.out.println("Palindrome number");
else
System.out.println("not a Palindrome number");
}}
INPUT/OUTPUT:
program checks a number is palindrome or not
Enter n
121
Palindrome number
RESULT:
Thus the program is executed successfully.
Program: 4
CALCULATING THE X SERIES USING FOR LOOP
AIM:
Write a java program to evaluate the sum of x series x-2x/2!+3x/3!-4x/4!+ .... n
terms
PROGRAM CODING :
import java.util.*;
class loop2
public static void main()
float x,n,i,s=0,f;
Scanner s1=new Scanner(System.in);
System.out.println("this program sum of x series x-2x/2!+3x/3!-4x/4!+ .... n
terms");
System.out.println("enter n");
n=s1.nextFloat();
System.out.println("enter x");
x=s1.nextFloat();
int sign=-1,j;
for(i=1;i<=n;i++)
{ f=1;
sign=sign*-1;
for(j=1;j<=i;j++)
f=f*j;
s=s+sign*(i*x/f);
System.out.println("Answer is"+s);
}}
INPUT/OUTPUT:
this program sum of x series x-2x/2!+3x/3!-4x/4!+ .... n terms
enter n
Enter x
Answer is 1
RESULT:
Thus the program is executed successfully.
Program: 5
FINDING THE NUMBER OF POSITIVE ODD, POSITIVE EVEN, NEGATIVE ODD
AND NEGATIVE EVEN NUMBER
AIM:
Write a java program to find the number of positive odd, positive even, negative
odd and negative even number using do..while statement.
PROGRAM CODING:
import java.util.*;
class loop3
public static void main()
int n,i,pe=0,ne=0,po=0,no=0,o=0;
Scanner s=new Scanner(System.in);
System.out.println("this program reads n numbers and counts no of odd &
positive number/n odd negative number /n even positive number /n even
negative nuber");
do
System.out.println("enter n");
n=s.nextInt();
if(n>0 && n%2==0)
pe++;
else if(n<0 && n%2==0)
ne++;
else if(n>0 && n%2==1)
po++;
else if(n<0 && n%2!=0)
no++;
}while(n!=0);
System.out.println("number of positive even numbers"+pe);
System.out.println("number of positive odd numbers"+po);
System.out.println("number of negative even numbers"+ne);
System.out.println("number of negative odd numbers"+no);
}}
INPUT/OUTPUT:
this program reads n numbers and counts no of odd & positive number
odd negative number
even positive number
even negative nuber
-1
number of positive even numbers 3
number of positive odd numbers 1
number of negative even numbers 0
number of negative odd numbers 1
RESULT:
Thus the program is executed successfully.
Program: 6
FIBONACCI SERIES
AIM:
Write a java program to generate a method fib to print the Fibonacci series till n
terms.
PROGRAM CODING :
import java.util.*;
class method1
void fib()
int f=0, se=1, i, n,t;
Scanner s=new Scanner(System.in);
System.out.println("enter n terms");
n=s.nextInt();
System.out.print(f+" "+se);
for(i=3;i<=n;i++)
t=f+se;
f=se;
se=t;
System.out.print(" "+t);
public static void main()
{
method1 m=new method1();
m.fib();
}}
INPUT/OUTPUT :
enter n terms
0 1 1 23 5 8
RESULT:
Thus the program is executed successfully.
Program: 7
PRIME NUMBER
AIM :
Write a java program to create a method prime which receives a number and
checks whether it is a prime or not.
PROGRAM CODING :
import java.util.*;
class prime
void pri(int n)
int i,c=0;
for(i=1;i<=n;i++)
if(n%i==0)
c++;
if(c==2)
System.out.println(n+"is a prime number");
else
System.out.println(n+"is not a prime number");
public static void main()
int n;
prime p=new prime();
Scanner s=new Scanner(System.in);
System.out.println("enter n");
n=s.nextInt();
p.pri(n);
}}
INPUT/OUTPUT:
enter n
5 is a prime number
RESULT:
Thus the program is executed successfully.
Program: 8
ARMSTRONG NUMBER
AIM:
Write a java program to create a method which checks a number is Armstrong
number or not and it returns a value 1 if it is Armstrong or returns 0.
PROGRAM CODING:
import java.util.*;
class armstr
int arms()
int n,i,s=0,d,orig_n;
Scanner sc=new Scanner(System.in);
System.out.println("enter n");
n=sc.nextInt();
orig_n=n;
for(;n>0;n=n/10)
d=n%10;
s=s+d*d*d;
if(orig_n==s)
return 1;
else
return 0;
public static void main()
{
armstr a=new armstr();
int x=a.arms();
if(x==1)
System.out.println("given is an Armstrong number");
else
System.out.println("given is not an Armstrong number");
}}
INPUT/OUTPUT:
Enter n
345
given is not an Armstrong number
RESULT:
Thus the program is executed successfully.
Program: 9
STUDENT’S MARKLIST
AIM:
Write a java program to define a class student with the descriptions rollno,
name, marks of 5 subjects, total and average and initialize the above members
using constructors and calculate the average.
PROGRAM CODING:
import java.util.*;
class cons1
int rno;
String n;
float m1,m2,m3,m4,m5,tot,avg;
public cons1()
rno=0;
n=" ";
m1=0;
m2=0;
m3=0;
m4=0;
m5=0;
tot=0;
avg=0;}
public cons1(int r,String nm,float mk1,float mk2,float mk3,float mk4,float mk5)
rno=r;
n=nm;
m1=mk1;
m2=mk2;
m3=mk3;
m4=mk4;
m5=mk5;
tot=0;
avg=0;}
public void calc()
tot=m1+m2+m3+m4+m5;
avg=tot/5;
void dis()
System.out.println("Roll no:"+ rno+"\n Name:"+ n+"\nmark1: "+ m1+"\
nMark2"+m2+"\nMark3"+m3+"\nMark4"+m4+"\nMark5:"+m5+"\nTotal:"+tot+"\
n average:"+avg);
public static void main()
cons1 c=new cons1();
//c.dis();
cons1 c1=new cons1(5,"anu",67,78,89,90,97);
c1.dis();
}}
INPUT/OUTPUT:
Roll no: 5
Name: anu
Mark1: 67
Mark2: 78
Mark3: 89
Mark4: 90
Mark5: 97
Total: 421
average: 84.2
RESULT:
Thus the program is executed successfully.
Program: 10
STRING FUNCTIONS USING LIBRARY CLASSES
AIM:
Write a menu driven program to change the string into uppercase and lowercase,
finding the length of a string, combine the strings, reverse a string, find a
position of a substring and compare the two strings using library classes.
PROGRAM CODING:
import java.util.*;
class string
static Scanner sc=new Scanner(System.in);
static void s(String x)
int ch;
System.out.println("enter ch\n1.to upper case\n2.lowercase\n3.string length\
n4.combine the string \n5. reverse\n6.find position of a character\n7.string
compare\n8.substring");
ch=sc.nextInt();
switch(ch)
case 1: System.out.println("result is "+x.toUpperCase());
break;
case 2:System.out.println("result is "+x.toLowerCase());
break;
case 3:System.out.println("result is "+x.length());
break;
case 4:System.out.println("enter the other string");
String x1=sc.next();
System.out.println("result is "+x.concat(x1));
break;
case 5:System.out.println("result is "+x.reverse());
break;
case 6:System.out.println("result is "+x.indexof('d'));
break;
case 7:System.out.println("enter the other string");
String x11=sc.next();
if(x.equals(x11))
System.out.println("Strings are same");
else
System.out.println("Strings are not same");
break;
case 8:System.out.println("enter the other string");
String xx1=sc.next();
System.out.println("sub string is "+x.substring(3,8));
}}
public static void main()
string ob=new string();
String x;
System.out.println("enter a string");
x=sc.next();
s(x);
}}
INPUT/OUTPUT:
enter a string
COMPUTER
enter ch
1.to upper case
2.lowercase
3.string length
4.combine the string
5. reverse
6.find position of a character
7.string compare
8.substring
computer
RESULT:
Thus the program is executed successfully.
Program: 11
PALINDROME
AIM:
Special words are those words which start and end with the same
letter.
Example: EXISTENCE, COMIC, WINDOW
Palindrome words are those words which read the same from left to right
and vice-versa.
Example: MALYALAM, MADAM, LEVEL, ROTATOR, CIVIC
All palindromes are special words but all special words are not palindromes.
Write a program to accept a word. Check and display whether the word is a
palindrome or only a special word or none of them.
PROGRAM CODING:
import java.util.*;
class Palin
{ static void main()
{ Scanner sc=new Scanner(System.in);
System.out.println(“Enter a word”);
String s=sc.next();
String rv=””;
for(int i=0;i<s.length();i++)
rv=s.charAt(i)+rv;
if(s.equals(rv))
System.out.println(“Palindrome string”);
else
System.out.println(“Not a Palindrome string”);
}}
INPUT/OUTPUT: Enter a word noon
Palindrome string
RESULT:
Thus the program is executed successfully.
Program :12
STRING PATTERN
AIM:
Write a program to generate a triangle or an inverted triangle till n terms based
upon the User’s choice of the triangle to be displayed.
Example 1:
Input: Type 1 for a triangle and
Type 2 for an inverted triangle
Enter your choice 1
Enter the number of terms 5
Sample Output:
*****
****
***
**
*
Example 2:
Input: Type 1 for a triangle and
Type 2 for an inverted triangle
Enter your choice 2
Enter the number of terms 5
Sample Output:
ABCDE
ABCD
ABC
AB
A
import java.util.Scanner;
public class Menu
{
public static void main() {
Scanner sc = new Scanner(System.in);
System.out.println("Type 1 for a triangle and");
System.out.println("Type 2 for an inverted triangle of alphabets");
System.out.print("Enter your choice: ");
int ch = sc.nextInt();
System.out.print("Enter the number of terms: ");
int n = sc.nextInt();
switch (ch) {
case 1:
for (int i = 0; i <= n; i++) {
for (int j = 0; j < i; j++) {
System.out.print(' ');
}
for (int k = i; k <= n; k++) {
System.out.print('*');
}
System.out.println();
}
break;
case 2:
for (char i = ‘E’; i >= ‘A’; i--) {
for (char j = ‘A’; j <= i; j++) {
System.out.print(j);
}
System.out.println();
}
break;
default:
System.out.println("Incorrect choice");
break;
}
}
}
INPUT/OUTPUT
RESULT:
Thus the program is executed successfully.
Program: 13
SEARCHING
AIM:
Write a program in Java to store 10 different country names and their capitals
in two different Single Dimensional Arrays (SDA). Display the country names
(that starts with a vowel) along with their capitals in the given format.
Country Names Capital
xxxx xxxx
xxxx xxxx
PROGRAM CODING:
import java.util.Scanner;
public class City
{
public static void main() {
final int SIZE = 10;
Scanner in = new Scanner(System.in);
String cnt[] = new String[SIZE];
String cap[] = new String[SIZE];
System.out.println("Enter " + SIZE
+ " countries and their capitals");
for (int i = 0; i < SIZE; i++) {
System.out.print("Enter country name: ");
cnt[i] = in.nextLine();
System.out.print("Enter its capital: ");
cap[i] = in.nextLine();
}
System.out.println("Country Names\t\tCapital");
for (int i = 0; i < SIZE; i++) {
char ch = Character.toUpperCase(cnt[i].charAt(0));
if (ch == 'A' ||
ch == 'E' ||
ch == 'I' ||
ch == 'O' ||
ch == 'U') {
System.out.println(countries[i] + "\t\t" + cap[i]);
}
}
}
}
INPUT/OUTPUT
RESULT:
Thus the program executed successfully.
Program: 14
BUBBLE SORT
AIM:
Write a program to input twenty names in an array. Arrange these names in
ascending order of letters, using the bubble sort technique.
Sample Input:
Rohit, Devesh, Indrani, Shivangi, Himanshu, Rishi, Piyush, Deepak, Abhishek,
Kunal, .....
Sample Output:
Abhishek, Deepak, Devesh, Himanshu, Indrani, Kunal, Piyush, Rishi, Rohit,
Shivangi, .....
PROGRAM CODING:
import java.util.Scanner;
public class sortNm
{
public static void main() {
Scanner in = new Scanner(System.in);
String nms[] = new String[20];
System.out.println("Enter 20 names:");
for (int i = 0; i < nms.length; i++) {
nms[i] = in.nextLine();
}
//Bubble Sort
for (int i = 0; i < nms.length - 1; i++) {
for (int j = 0; j < nms.length - 1 - i; j++) {
if (nms[j].compareToIgnoreCase(nms[j + 1]) > 0) {
String t = nms[j + 1];
nms[j + 1] = nms[j];
nms[j] = t;
}
}
}
System.out.println("\nSorted Names");
for (int i = 0; i < nms.length; i++) {
System.out.println(nms[i]);
}
}
}
INPUT/OUTPUT:
RESULT:
Thus the program executed successfully.
Program: 15
CALCULATING AVERAGE
AIM:
Write a program to accept name and total marks of N number of students in two
single subscript arrays name[ ] and totalmarks[ ].
Calculate and print:
(i) The average of the total marks obtained by N number of students.
[average = (sum of total marks of all the students)/N]
(ii) Deviation of each student's total marks with the average.
[deviation = total marks of a student - average]
PROGRAM CODING:
import java.util.Scanner;
public class Marks
{
public static void main() {
Scanner in = new Scanner(System.in);
System.out.print("Enter number of students: ");
int n = in.nextInt();
String name[] = new String[n];
int tot[] = new int[n];
int gTot = 0;
for (int i = 0; i < n; i++) {
System.out.print("Enter name of student " + (i+1) + ": ");
name[i] = in.nextLine();
System.out.print("Enter total marks of student " + (i+1) + ": ");
tot[i] = in.nextInt();
gTot += tot[i];
}
double avg = grandTotal / (double)n;
System.out.println("Average = " + avg);
for (int i = 0; i < n; i++) {
System.out.println("Deviation for " + name[i] + " = "
+ (tot[i] - avg));
}
}
}
INPUT/OUTPUT:
RESULT:
Thus the program executed successfully.
Program: 16
SELECTION SORT IN NUMBERS
AIM:
Write a program to accept a list of 20 integers. Sort the first 10 numbers in
ascending order and next the 10 numbers in descending order by using 'Bubble
Sort' technique. Finally, print the complete list of integers.
PROGRAM CODING:
import java.util.Scanner;
public class SSort
{
public static void main() {
Scanner in = new Scanner(System.in);
int arr[] = new int[20];
System.out.println("Enter 20 numbers:");
for (int i = 0; i < arr.length; i++) {
arr[i] = in.nextInt();
}
//Sort first half in ascending order
for (int i = 0; i < arr.length ; i++) {
int sm=i;
for (int j = i+1; j < arr.length; j++) {
if (arr[sm] > arr[j])
sm=j; }
int t = arr[i];
arr[i] = arr[sm];
arr[sm] = t;
}
//Print the final sorted array
System.out.println("\nSorted Array:");
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
}
}
Output
RESULT:
Thus the program executed successfully.
Program: 17
ODD/EVEN
Write a program in Java to accept 20 numbers in a single dimensional array
arr[20]. Transfer and store all the even numbers in an array even[ ] and all the
odd numbers in another array odd[ ]. Finally, print the elements of both the
arrays.
import java.util.Scanner;
public class KboatSDAEvenOdd
{
public static void main(String args[]) {
int N= 20;
Scanner in = new Scanner(System.in);
int i = 0;
int arr[] = new int[N];
int even[] = new int[N];
int odd[] = new int[N];
System.out.println("Enter 20 numbers:");
for (i = 0; i < N; i++) {
arr[i] = in.nextInt();
}
int e = 0, od = 0;
for (i = 0; i < N; i++) {
if (arr[i] % 2 == 0)
even[e++] = arr[i];
else
odd[od++] = arr[i];
}
System.out.println("Even Numbers:");
for (i = 0; i < e; i++) {
System.out.print(even[i] + " ");
}
System.out.println("\nOdd Numbers:");
for (i = 0; i < od; i++) {
System.out.print(odd[i] + " ");
}
}
}
Output
RESULT:
Thus the program executed successfully.
Program: 18
CONSTRUCTOR-I
AIM:
Define a class named FruitJuice with the following description:
Data Members Purpose
int product_code stores the product code number
String flavour stores the flavour of the juice (e.g., orange, apple, etc.)
stores the type of packaging (e.g., tera-pack, PET bottle,
String pack_type
etc.)
int pack_size stores package size (e.g., 200 mL, 400 mL, etc.)
int product_price stores the price of the product
Member
Purpose
Methods
constructor to initialize integer data members to 0 and
FruitJuice()
string data members to ""
to input and store the product code, flavour, pack type,
void input()
pack size and product price
void discount() to reduce the product price by 10
to display the product code, flavour, pack type, pack
void display()
size and product price
PROGRAM CODING:
import java.util.Scanner;
public class FruitJuice
{
private int p_code;
private String flr;
private String p_type;
private int p_size;
private int p_price;
public FruitJuice() {
p_code = 0;
flr = "";
p_type = "";
p_size = 0;
p_price = 0;
}
public void input() {
Scanner in = new Scanner(System.in);
System.out.print("Enter Flavour: ");
flr = in.nextLine();
System.out.print("Enter Pack Type: ");
p_type = in.nextLine();
System.out.print("Enter Product Code: ");
p_code = in.nextInt();
System.out.print("Enter Pack Size: ");
p_size = in.nextInt();
System.out.print("Enter Product Price: ");
p_price = in.nextInt();
}
public void dis() {
p_price -= 10;
}
public void display() {
System.out.println("Product Code: " + p_code);
System.out.println("Flavour: " + flr);
System.out.println("Pack Type: " + p_type);
System.out.println("Pack Size: " + p_size);
System.out.println("Product Price: " + p_price);
}
public static void main(String args[]) {
FruitJuice obj = new FruitJuice();
obj.input();
obj.dis();
obj.display();
}
}
Output
RESULT:
Thus the program executed successfully.
Program: 19
CALCULATING EMPLOYEES SALARY
AIM:
The basic salary of employees is undergoing a revision. Define a class called
Grade_Revision with the following specifications:
Data Members Purpose
String name to store name of the employee
int bas to store basic salary
int expn to consider the length of service as an experience
double inc to store increment
double nbas to store new basic salary (basic + increment)
Member
Purpose
Methods
Grade_Revision() constructor to initialize all data members
void accept() to input name, basic and experience
to calculate increment based on experience as per the
void increment()
table given below
void display() to print all the details of an employee
Experience Increment
Up to 3 years ₹1,000 + 10% of basic
3 years or more and up to 5 years ₹3,000 + 12% of basic
Experience Increment
5 years or more and up to 10 years ₹5,000 + 15% of basic
10 years or more ₹8,000 + 20% of basic
Write the main method to create an object of the class and call all the member
methods.
PROGRAM CODING
import java.util.Scanner;
public class Grade_Revision
{
private String nm;
private int bas;
private int expn;
private double inc;
private double nbas;
public Grade_Revision() {
nm = "";
bas = 0;
expn = 0;
inc = 0.0;
nbas = 0.0;
}
public void accept() {
Scanner in = new Scanner(System.in);
System.out.print("Enter name: ");
nm = in.nextLine();
System.out.print("Enter basic: ");
bas = in.nextInt();
System.out.print("Enter experience: ");
expn = in.nextInt();
}
public void incr() {
if (expn <= 3)
inc = 1000 + (bas * 0.1);
else if (expn <= 5)
inc = 3000 + (bas * 0.12);
else if (expn <= 10)
inc = 5000 + (bas * 0.15);
else
inc = 8000 + (bas * 0.2);
nbas = bas + inc;
}
public void disp() {
System.out.println("Name: " + nm);
System.out.println("Basic: " + bas);
System.out.println("Experience: " + expn);
System.out.println("Increment: " + inc);
System.out.println("New Basic: " + nbas);
}
public static void main(String args[]) {
Grade_Revision obj = new Grade_Revision();
obj.accept();
obj.incr();
obj.disp();
}
}
Output
RESULT:
Thus the program executed successfully.
Program: 20
TELEPHONE BILL
AIM:
Define a class Bill that calculates the telephone bill of a consumer with the
following description:
Data Members Purpose
int bno bill number
String name name of consumer
int call no. of calls consumed in a month
double amt bill amount to be paid by the person
Member
Purpose
Methods
constructor to initialize data members with default initial
Bill()
value
parameterised constructor to accept billno, name and no. of
Bill(...)
calls consumed
to calculate the monthly telephone bill for a consumer as
Calculate()
per the table given below
Display() to display the details
Units consumed Rate
First 100 calls ₹0.60 / call
Next 100 calls ₹0.80 / call
Units consumed Rate
Next 100 calls ₹1.20 / call
Above 300 calls ₹1.50 / call
Fixed monthly rental applicable to all consumers: ₹125
Create an object in the main() method and invoke the above functions to
perform the desired task.
PROGRAM CODING
import java.util.Scanner;
public class Bill
{
private int bno;
private String name;
private int call;
private double amt;
public Bill() {
bno = 0;
name = "";
call = 0;
amt = 0.0;
}
public Bill(int b, String n, int c) {
this.bno = b;
this.name = n;
this.call = c;
}
public void calculate() {
double ch;
if (call <= 100)
ch = call * 0.6;
else if (call <= 200)
ch = 60 + ((call - 100) * 0.8);
else if (call <= 300)
ch = 60 + 80 + ((call - 200) * 1.2);
else
ch = 60 + 80 + 120 + ((call - 300) * 1.5);
amt = ch + 125;
}
public void display() {
System.out.println("Bill No: " + bno);
System.out.println("Name: " + name);
System.out.println("Calls: " + call);
System.out.println("Amount Payable: " + amt);
}
public static void main() {
Scanner in = new Scanner(System.in);
System.out.print("Enter Name: ");
String csNM = in.nextLine();
System.out.print("Enter Bill Number: ");
int billNm = in.nextInt();
System.out.print("Enter Calls: ");
int nCalls = in.nextInt();
Bill obj = new Bill(billNm, csNM, nCalls);
obj.calculate();
obj.display();
}
}
Output
RESULT:
Thus the program executed successfully.