You are on page 1of 5

Ayush kumar

21MCA1004
1>The daily maximum temperatures recorded in 10 cities during the month of January. Write a Java
application to read the table elements into a 2-dimensional array temperature and to find the city
and day corresponding to highest temperature and lowest temperature.

import java.util.Scanner;

class Array
{
public static void main(String[] args)
{
int i,j;
int arr[][]=new int[30][30];
int max,min,maxc,maxd,minc,mind,m,n;

Scanner sc=new Scanner(System.in);


System.out.println("enter the value of city");
m=sc.nextInt();
System.out.println("enter the no of days");
n=sc.nextInt();

for(i=0;i<m;i++)
{

for(j=0;j<n;j++)
{
System.out.println("the temp of city is"+i+ "and day:"+j);

arr[i][j]=sc.nextInt();

}
}
max=arr[0][0];
min=arr[0][0];
maxc=minc=0;
maxd=mind=0;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(arr[i][j]>max)
{
max=arr[i][j];
maxc=i;
maxd=j;

}
else
{
if(arr[i][j]<min)
min=arr[i][j];
minc=i;
mind=j;

}
}

System.out.println("Temperatures: " + max + " for City: " + maxc + " and day :" + maxd + " is
Max!");
System.out.println("Temperatures: " + min + " for City: " + mind + " and day :" + mind + " is
Min!");
}

}
2>) In an educational institution, one of the M.Tech class with 30 students have the following
properties: Roll number, Name, Date of Birth, weight, height. Write a suitable constructor and a
method to display the details of all the students and also display roll numbers of the students who
are 19 years old or more with weight above 75 kg but height less than 172 cm.

import java.util.Scanner;

class Mtech{
int roll;
String name;
int age;
int weight;
int height;

Mtech(int roll,String name,int age,int weight,int height)


{
this.roll=roll;
this.name=name;
this.age=age;
this.weight=weight;
this.height=height;

void cal()
{
if(age>=19 && weight>75 && height<172)
{
print();
}
}
void print()
{

System.out.println("rollno-----"+roll);
System.out.println("name-----"+name);
System.out.println("age-----"+age);
System.out.println("height-----"+height);
System.out.println("weight-----"+weight);
}
}

class Main1
{

public static void main(String args[])


{
Scanner sc=new Scanner(System.in);
for(int i=0;i<2;i++)
{
int roll=sc.nextInt();
String name=sc.next();
int age=sc.nextInt();
int weight=sc.nextInt();
int height=sc.nextInt();

Mtech b=new Mtech(roll,name,age,weight,height);


b.cal();

}
}

3>In Chennai Corporation house tax is levied annually. If the house is under owner’s occupation
then the tax is levied as 0.5% of the total value of the property. If the property is rented, then 10% of
the annual rent is the annual house tax for the property.
Define a class House and a derived class RentedHouse and implement the taxing procedure. You
program should be repeat the process till the user wishes to continue.
import java.util.Scanner;
class own
{
int amount;
double tax;
Scanner sc=new Scanner(System.in);

void cal()
{
System.out.println("enter the amount");
amount=sc.nextInt();

tax=(amount*0.5)/100;
System.out.println("the tax of owner house is"+tax);
}
}
class Rent extends own
{
void ca()
{
tax=(amount*10)/100;
System.out.println("the tax of the renter house is"+tax);
}
}
class House
{
public static void main(String args[])
{
Rent obj=new Rent();
obj.cal();
obj.ca();
}

You might also like