Winter Sem 2019-2020
CSE1007 – Java Programming Lab
NAME: SHRUTI GARG REG NO:19BCE0994
LAB SLOT: L19+L20 DATE: 15-03-21
1. Write a program to find the factorial of a number using command line
arguments.
public class factorial {
public static void main(String[] args){
int a,b = 1;
int n = Integer.parseInt(args[0]);
for(a =1; a<=n ; a++)
{
b = b*a;
}
System.out.println("Factorial is " +b);
}
}
2. Write a program to print the multiplication table of a number.
package cyclesheet1;
import java.util.Scanner;
public class multiplicationTable {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
int n;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number: ");
n = sc.nextInt();
System.out.println("\nMultiplication Table of "+ n +" is :");
for(int i=1; i<=10; i++){
System.out.println(n+" * "+ i +" = " + n*i);
}
}
}
3. Write a program to check whether the given number is an Armstrong
number or not.
package cyclesheet1;
import java.util.Scanner;
import java.lang.Math;
public class ArmstrongNum {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
int num , count=0;
int n,n1, r;
double a=0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number : ");
num = sc.nextInt();
n=num;
n1=num;
while(n!=0){
n=n/10;
count++;
}
for(int i=0; i<count; i++){
r=n1%10;
a= Math.pow(r,count) + a;
n1=n1/10;
}
int result = (int) a;
if(result==num)
System.out.println("The given number is an Armstrong number!\n");
else
System.out.println("The given number is not an Armstrong number!\n");
}
}
4. Write a program to check whether the given number is a prime number or
not.
package cyclesheet1;
import java.util.Scanner;
public class PrimeNumber {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
int n;
boolean flag = false;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number: ");
n= sc.nextInt();
for(int i=2; i<n/2; i++){
if(n%i==0){
flag = true;
break;
}
else{
flag = false;
}
}
if(flag==true)
System.out.println("\nThe given number is not a prime number!");
else
System.out.println("\nThe given number is a prime number!");
}
}
5. Write a program to generate the following patterns.
i.
package cyclesheet1;
public class pattern1 {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
int n=3;
for(int i=1; i<=n; i++){
for(int j=1; j<=i; j++){
System.out.print(j + " ");
}
System.out.println(" ");
}
}
}
ii.
package cyclesheet1;
public class pattern2 {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
int n=3, a;
for(int i=1; i<=n; i++){
a=i;
while(n-a>=1) {
System.out.print(" ");
a++;
}
for(int j=1; j<=i; j++){
System.out.print("* ");
}
System.out.println(" ");
}
for(int i=n-1; i>=1; i--){
a=i;
while(n-a>=1) {
System.out.print(" ");
a++;
}
for(int j=1; j<=i; j++){
System.out.print("* ");
}
System.out.println(" ");
}
}
}
6. Write a program to generate the Fibonacci series.
package cyclesheet1;
import java.util.Scanner;
public class FibonacciSeries {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
int n;
int fib[];
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number: ");
n= sc.nextInt();
fib =new int[n];
fib[0]=0;
fib[1]=1;
for(int i=2; i<n; i++){
fib[i]=fib[i-1]+fib[i-2];
}
System.out.println("\nFibonacci series upto "+n+ " numbers is :");
for(int i=0; i<n; i++){
System.out.println(fib[i]);
}
}
}
7. Write a program to sort n numbers in ascending order.
package cyclesheet1;
import java.util.Scanner;
public class sortAscending {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
int n,arr[], temp;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the no. of values: ");
n=sc.nextInt();
arr= new int[n];
System.out.println("\nEnter the values to be sorted : ");
for(int i=0; i< arr.length; i++){
arr[i]=sc.nextInt();
}
for(int i=0; i<arr.length; i++){
for(int j=i+1; j< arr.length; j++){
if(arr[i]>arr[j]){
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
System.out.println("\nThe values in ascending order are: ");
for(int i=0; i< arr.length; i++)
System.out.print(arr[i] + " ");
}
}
8. Write a program to search a number among n numbers using binary search.
package cyclesheet1;
import java.util.Scanner;
public class binarySearch {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
int num,n,l,m ,u,arr[];
boolean key=false;
Scanner sc = new Scanner(System.in);
System.out.print("Enter the no. of values: ");
n=sc.nextInt();
arr= new int[n];
System.out.println("\nEnter the values : ");
for(int i=0; i< arr.length; i++){
arr[i]=sc.nextInt();
}
System.out.print("\nEnter the no. to be searched: ");
num=sc.nextInt();
l=0;
u=n-1;
while(l<u){
m=(l+u)/2;
if(num==arr[m]) {
System.out.println("Number found at " + (m + 1) + " position.");
key=true;
break;
}
if(num>arr[m])
l=m+1;
else
u=m-1;
}
if(key==false)
System.out.println("Number not found!!");
}
}
9. Write a program to read ‘n’ numbers and print their sum and average.
package cyclesheet1;
import java.util.Scanner;
public class sum_Average {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
int n,sum=0,arr[];
float avg=0.0f;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value of n: ");
n= sc.nextInt();
arr= new int [n];
System.out.println("Enter the numbers: ");
for(int i=0; i< arr.length; i++){
arr[i]=sc.nextInt();
}
for(int i=0; i<arr.length; i++){
sum= sum+arr[i];
}
System.out.println("\nSum = "+sum);
avg=(float)sum/(float)n;
System.out.println("Average ="+avg);
}
}
10.Write a program that accepts a number as input and convert them into
binary, octal and hexadecimal equivalents.
package cyclesheet1;
import java.util.Scanner;
public class numberConversion {
public static void toBinary(int num){
int binary[] = new int[50];
int i = 0;
while(num > 0){
binary[i] = num%2;
num = num/2;
i++;
}
System.out.print("Binary : ");
for(int j = i-1; j >= 0; j--){
System.out.print(binary[j]);
}
System.out.println();
}
public static void toOctal(int num){
int rem;
String octal="";
char octalchars[]={'0','1','2','3','4','5','6','7'};
while(num>0){
rem=num%8;
octal=octalchars[rem]+octal;
num=num/8;
}
System.out.println("Octal : "+octal);
}
public static void toHex(int num) {
int rem;
String hex = "";
char hexchars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A',
'B', 'C', 'D', 'E', 'F'};
while (num > 0) {
rem = num % 16;
hex = hexchars[rem] + hex;
num = num / 16;
}
System.out.println("Hexadecimal : " + hex);
public static void main(String args[]) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
int n;
Scanner sc = new Scanner(System.in);
System.out.println("Enter any number: ");
n= sc.nextInt();
toBinary(n);
toOctal(n);
toHex(n);
}
}
11.Write a menu driven program to i) append a string ii) insert a string iii)
delete a portion of the string.
package cyclesheet1;
import java.lang.*;
import java.util.Scanner;
public class stringFunc
{
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
Scanner sc=new Scanner(System.in);
System.out.println("Enter the initial string: ");
StringBuffer sb=new StringBuffer();
sb.append(sc.nextLine());
int choice,n,startindex,endindex;
String str=new String();
System.out.println("Enter \n1.For appending. \n2.For insertion. \n3.For
deletion.");
choice=sc.nextInt();
sc.nextLine();
switch(choice)
{
case 1:System.out.println("Enter the string to be appended: ");
str=sc.nextLine();
sb.append(str);
System.out.println(sb);
break;
case 2:System.out.println("Enter the string to be inserted: ");
str=sc.nextLine();
System.out.println("Enter the position: ");
n=sc.nextInt();
sb.insert(n,str);
System.out.println(sb);
break;
case 3: System.out.print("Enter the start index:");
startindex=sc.nextInt();
System.out.print("\nEnter the end index: ");
endindex=sc.nextInt();
sb.delete(startindex,endindex);
System.out.println(sb);
break;
}
}
}
12.Write a program to check whether a string is palindrome or not without
using functions.
package cyclesheet1;
import java.util.Scanner;
public class Palindrome {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
System.out.println("Enter any string : ");
Scanner sc = new Scanner(System.in);
String oldstr = sc.nextLine();
int length = oldstr.length();
boolean isPalindrome = true;
for(int i = 0; i < length; i++)
{
if(oldstr.charAt(i) != oldstr.charAt(length-1-i)) {
System.out.println("String is not a palindrome.");
isPalindrome = false;
break;
}
}
if(isPalindrome) {
System.out.println("String is a palindrome.");
}
}
}
13.Write a menu driven program to i) compare two strings ii) get the character
in the specified position iii) extract a substring iv) replace a character with
the given character v) get the position of a specified substring/character.
package cyclesheet1;
import java.util.*;
public class stringfunc2
{
static void cmp()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter 2 Strings");
String s1 = new String();
String s2 = new String();
s1= sc.next();
s2=sc.next();
System.out.println(s1.compareTo(s2));
}
static void Get_char()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a String and an index");
String s1 = new String();
s1= sc.next();
int i = sc.nextInt();
System.out.println(s1.charAt(i));
}
static void ext()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a string, start index and end Index");
String s1 = new String();
s1= sc.next();
int s = sc.nextInt();
int e = sc.nextInt();
System.out.println(s1.substring(s,e));
}
static void rep()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a Strings, a character and another character to
replce with");
String s1 = new String();
s1= sc.next();
char c = sc.next().charAt(0);
char r = sc.next().charAt(0);
System.out.println(s1.replace(c,r));
}
static void getp()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a String and a Substring/character");
String s1 = new String();
String s2 = new String();
s1= sc.next();
s2=sc.next();
System.out.println(s1.indexOf(s2));
}
public static void main(String args[])
{
System.out.println("\nSHRUTI GARG 19BCE0994\n");
Scanner sc = new Scanner(System.in);
int c;
while(true)
{
System.out.println("EnterChoice:\n1.Compare\n2.Get_char\n3.Extract
substring\n4.replace Char\n5.Get position\n6.Exit");
c = sc.nextInt();
switch(c)
{
case 1:
cmp();
break;
case 2:
Get_char();
break;
case 3:
ext();
break;
case 4:
rep();
break;
case 5:
getp();
break;
case 6:
System.exit(0);
break;
default:
System.out.println("Wrong Choice");
break;
}
}
}
}
14.Write a program to change the case of the letters in a string. Eg. ABCdef
abcDEF
package cyclesheet1;
import java.util.Scanner;
public class caseChange {
public static void main(String[] args) {
System.out.println("\nSHRUTI GARG 19BCE0994\n");
String str;
Scanner sc=new Scanner(System.in);
System.out.println("Enter a string: ");
str= sc.nextLine();
StringBuffer newStr=new StringBuffer(str);
for(int i = 0; i < str.length(); i++) {
if(Character.isLowerCase(str.charAt(i)))
newStr.setCharAt(i, Character.toUpperCase(str.charAt(i)));
else if(Character.isUpperCase(str.charAt(i)))
newStr.setCharAt(i, Character.toLowerCase(str.charAt(i)));
}
System.out.println("String after changing case : " + newStr);
}
}
15.Write a class with the following methods:
wordCount: This method accepts a String object as an argument and returns the
number of words contained in the object.
arrayToString: This method accepts a char array as an argument and converts it to
a String object.
mostFrequent: This method accepts a String object as an argument and returns the
character that occurs the most frequently in the object.
package cyclesheet1;
import java.lang.*;
import java.util.*;
class Stringfns
{
Scanner sc= new Scanner(System.in);
String s1;
void getString()
{
System.out.println("\nEnter a string: ");
s1=sc.nextLine();
}
int wordCount()
{
int i,ctr=0;
for (i=0;i<s1.length();i++)
{
if (s1.charAt(i)==' ')
ctr++;
}
ctr++;
return ctr;
}
String arrayToString(char array[])
{
s1=String.valueOf(array);
return s1;
}
char mostFrequent()
{
char
letters[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s
','t','u','v','w','x','y','z'};
int count[];
count = new int [26];
for(int i=0;i<26;i++)
count[i]=0;
for(int i=0;i<26;i++)
{
for (int j=0;j<s1.length();j++)
{
if (letters[i]==s1.charAt(j))
{
count[i]++;
}
}
}
int max=0;
for (int i=1;i<26;i++)
{
if (count[i]>count[max])
max=i;
}
return letters[max];
}
}
public class methods_q15
{
public static void main(String[] args)
{
System.out.println("\nSHRUTI GARG 19BCE0994");
Scanner sc= new Scanner(System.in);
Stringfns str;
str= new Stringfns();
str.getString();
int count=str.wordCount();
System.out.println("The number of words are " + count);
int i,n;
char array[];
String str2=new String();
array =new char [20];
System.out.println("\nEnter the number of characters:");
n=sc.nextInt();
System.out.println("Enter a character array: ");
for (i=0;i<n;i++)
array[i]=sc.next().charAt(0);
str2=str.arrayToString(array);
System.out.println("The string is " + str2);
str.getString();
char maxfr=str.mostFrequent();
System.out.println("The most frequent character is :" + maxfr);
}
}
16.Create a class Student (Regno, Name, Branch, Year, Semester and 5 Marks).
Add methods to read the student details, calculate the grade and print the
mark statement.
package cyclesheet1;
import java.util.Scanner;
public class student
{
public String s1,s2,s3;
public int n,sem,m1,m2,m3,m4,m5;
public float sum,avg;
public char grade;
public void details()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter name of student: ");
s1= sc.nextLine();
System.out.print("Enter reg no: ");
s2=sc.nextLine();
System.out.print("Enter branch: ");
s3= sc.nextLine();
System.out.print("Enter year: ");
n= sc.nextInt();
System.out.print("Enter semester: ");
sem=sc.nextInt();
System.out.print("Enter marks of subj 1: ");
m1=sc.nextInt();
System.out.print("Enter marks of subj 2: ");
m2=sc.nextInt();
System.out.print("Enter marks of subj 3: ");
m3= sc.nextInt();
System.out.print("Enter marks subj 4: ");
m4=sc.nextInt();
System.out.print("Enter marks of subj 5: ");
m5=sc.nextInt();
}
public void calc()
{
sum=m1+m2+m3+m4+m5;
avg=sum/5;
if (avg>=90)
{
grade='A';
}
else if (avg>=80)
{
grade='B';
}
else if (avg>=70)
{
grade='C';
}
else if(avg>50)
{
grade='D';
}
else
grade='E';
}
public void output()
{
System.out.println("\nName is"+s1);
System.out.println("Reg no is"+s2);
System.out.println("Branch "+s3);
System.out.println("Year is"+n);
System.out.println("Semester"+sem);
System.out.println("Sum of marks of all subjects"+sum);
System.out.println("Average of all subjects"+avg);
System.out.println("Grage is"+grade);
}
public static void main(String[] args)
{
System.out.println("\nSHRUTI GARG 19BCE0994\n");
Scanner sc=new Scanner(System.in);
student stu=new student();
stu.details();
stu.calc();
stu.output();
}
}
17.Write a program that displays an invoice of several items. Create a class
called Item with members item_name, quantity, price and total_cost and
methods to get and set values for the members. Derive a new class to print
the bill using Item class.
package cyclesheet1;
import java.lang.*;
import java.util.*;
class item
{
Scanner sc=new Scanner(System.in);
String item_name;
float quantity,item_price;
public void get()
{
System.out.print("Enter the item name: ");
item_name=sc.nextLine();
System.out.print("Enter the quantity of item: ");
quantity=sc.nextInt();
System.out.print("Enter the price of item: ");
item_price=sc.nextFloat();
}
public void display()
{
System.out.println("The item name is "+item_name);
System.out.println("The quantity is "+quantity);
System.out.println("The cost is "+item_price);
}
}
public class invoice extends item
{
public static void main(String arg[])
{
System.out.println("\nSHRUTI GARG 19BCE0994\n");
Scanner sc=new Scanner(System.in);
item obj [];
obj = new item[100];
int n,i;
float price=0;
System.out.print("Enter the no. of items: ");
n=sc.nextInt();
for(i=0;i<n;i++)
{
obj[i]=new item();
obj[i].get();
System.out.println();
}
for(i=0;i<n;i++)
{
obj[i].display();
System.out.println();
}
for(i=0;i<n;i++)
{
price=price+obj[i].item_price*obj[i].quantity;
}
System.out.println("\nThe total cost is "+price);
}
}
18.Create a class Telephone with two members to hold customer’s name and
phone number. The class should have appropriate constructor, input and
display methods. Derive a class TelephoneIndex with methods to change the
name or phone number.Create an array of objects and perform the
following functions.
a. Search for a name when the user enters a name or the first few characters.
b. Display all of the names that match the user’s input and their corresponding
phone numbers.
c. Change the name of a customer.
d. Change the phone number of a customer.
package cyclesheet1;
import java.lang.*;
import java.util.*;
class Telephone
{
String cName;
long phoneNo;
Scanner sc=new Scanner(System.in);
Telephone()
{
cName="Shruti";
phoneNo=100000;
}
void getTelephone()
{
System.out.println("Enter the customer's name: ");
cName=sc.nextLine();
System.out.println("Enter the customer's phone number: ");
phoneNo=sc.nextLong();
}
void printTelephone()
{
System.out.println("Customer name: "+cName);
System.out.println("Phone Number: "+phoneNo);
}
}
class TelephoneIndex extends Telephone
{
Scanner sc = new Scanner(System.in);
void updateName()
{
char ch;
System.out.println("Change customer name? (y/n)");
ch=sc.next().charAt(0);
sc.nextLine();
if (ch=='y' || ch=='Y')
{
System.out.println("Enter the new name: ");
cName=sc.nextLine();
}
}
void updateNo()
{
char ch;
System.out.println("Change phone number? (y/n)");
ch=sc.next().charAt(0);
sc.nextLine();
if (ch=='y' || ch=='Y')
{
System.out.println("Enter the new phone number: ");
phoneNo=sc.nextLong();
}
}
void search(String str)
{
if (cName.indexOf(str)==0)
{
printTelephone();
updateName();
updateNo();
}
}
}
public class Phone
{
public static void main(String[] args)
{
System.out.println("\nSHRUTI GARG 19BCE0994\n");
Scanner sc =new Scanner(System.in);
TelephoneIndex obj1[];
obj1=new TelephoneIndex[10];
System.out.println("Enter the number of records: ");
int n=sc.nextInt();
for (int i=0;i<n;i++)
{
obj1[i] = new TelephoneIndex();
obj1[i].getTelephone();
}
sc.nextLine();
String searchString= new String();
System.out.println("Enter the search string: ");
searchString=sc.nextLine();
for (int i=0; i<n;i++)
{
obj1[i].search(searchString);
}
}
}
19. Create an abstract class called BankAccount with members customer
name, date of birth, address, account number, balance and member functions
to get values for the members and display it. Derive a class SavingsAccount
with member functions to perform deposit and withdraw in the account. Write
a menu driven program to create a new account, perform withdraw, deposit
and delete an account.
package cyclesheet1;
import java.lang.*;
import java.util.*;
abstract class BankAccount
{
Scanner sc= new Scanner(System.in);
String cName;
String dob;
String address;
int accno;
float balance;
void getValues()
{
System.out.println("Enter the customer's name: ");
cName=sc.nextLine();
System.out.println("Enter the date of birth: ");
dob=sc.nextLine();
System.out.println("Enter the address: ");
address=sc.nextLine();
System.out.println("Enter the account number: ");
accno=sc.nextInt();
System.out.println("Enter the balance: ");
balance=sc.nextFloat();
}
void printValues()
{
System.out.println("Customer's Name: "+cName);
System.out.println("Date of birth: "+dob);
System.out.println("Address: "+address);
System.out.println("Account number: "+accno);
System.out.println("Balance: "+balance);
}
protected void finalize()
{
System.out.println("Account deleted!");
}
};
class SavingsAccount extends BankAccount
{
void deposit()
{
float amount;
System.out.println("Enter the amount to be deposited: ");
amount=sc.nextFloat();
balance=balance+amount;
System.out.println("The new balance is :"+balance);
}
void withdraw()
{
float amount;
System.out.println("Enter the amount to be withdrawn: ");
amount=sc.nextFloat();
balance=balance-amount;
System.out.println("The new balance is :"+balance);
}
};
public class bankTest
{
public static void main(String[] args)
{
int i=-1,flag=0;
Scanner sc= new Scanner(System.in);
SavingsAccount obj [];
obj = new SavingsAccount[10];
char ch;
int choice;
System.out.println("\nSHRUTI GARG 19BCE0994\n");
System.out.println("Banking system\n");
do
{
System.out.println("Enter your choice: ");
System.out.println("1. Create new account");
System.out.println("2. Deposit");
System.out.println("3. Withdraw");
System.out.println("4. Delete account");
choice=sc.nextInt();
switch(choice)
{
case 1: i++;
obj[i]=new SavingsAccount();
obj[i].getValues();
System.out.println("Account created!");
obj[i].printValues();
break;
case 2: obj[i].deposit();
break;
case 3: obj[i].withdraw();
break;
case 4: obj[i].finalize();
break;
default: System.out.println("Please enter a valid choice");
break;
}
System.out.println("Would you like to continue? (y/n)");
ch=sc.next().charAt(0);
} while ((ch=='y' || ch=='Y')&&(i<10));
}
}
20. Create an Interface with methods add(), sub(), multiply() and divide().
Write two classes FloatValues to perform arithmetic operations on floating
point numbers and IntegerValues on integer numbers by implementing the
interface.
package cyclesheet1;
import java.lang.*;
import java.util.Scanner;
interface add{
default void addf(float a,float b)
{
System.out.println("The float add is: "+(a+b));
}
default void addi(int c,int d)
{
System.out.println("The int add is: "+(c+d));
}
}
interface sub{
default void subf(float a,float b)
{
System.out.println("The float sub is: "+(a-b));
}
default void subi(int c,int d)
{
System.out.println("The int sub is: "+(c-d));
}
}
interface mul{
default void mulf(float a,float b)
{
System.out.println("The float multiplication is: "+(a*b));
}
default void muli(int c,int d)
{
System.out.println("The int mul is: "+(c*d));
}
}
interface div{
default void divf(float a,float b)
{
System.out.println("The float division is: "+(a/b));
}
default void divi(int c,int d)
{
System.out.println("The int div is: "+(c/d));
}
}
class floatvalues implements add,sub,mul,div{
void add(float a,float b)
{
add.super.addf(a,b);
}
void sub(float a,float b)
{
sub.super.subf(a,b);
}
void mul(float a,float b)
{
mul.super.mulf(a,b);
}
void div(float a,float b)
{
div.super.divf(a,b);
}
}
class intvalues implements add,sub,mul,div{
void add(int c,int d)
{
add.super.addi(c,d);
}
void sub(int c,int d)
{
sub.super.subi(c,d);
}
void mul(int c,int d)
{
mul.super.muli(c,d);
}
void div(int c,int d)
{
div.super.divi(c,d);
}
}
class test{
public static void main(String args[])
{
System.out.println("\nSHRUTI GARG 19BCE0994\n");
Scanner sc=new Scanner(System.in);
float a,b;
int c,d;
System.out.println("Integer:");
System.out.print("Enter number 1: ");
c=sc.nextInt();
System.out.print("Enter number 2: ");
d=sc.nextInt();
System.out.println("\nFloat:");
System.out.print("Enter number 1: ");
a=sc.nextFloat();
System.out.print("Enter number 2: ");
b=sc.nextFloat();
System.out.println();
intvalues obj=new intvalues();
obj.add(c,d);
obj.sub(c,d);
obj.mul(c,d);
obj.div(c,d);
System.out.println();
floatvalues dj=new floatvalues();
dj.add(a,b);
dj.sub(a,b);
dj.mul(a,b);
dj.div(a,b);
}
}