0% found this document useful (0 votes)
13 views2 pages

Shoe

The document contains a Java program that defines a 'Shoe' class with attributes such as batch number, type, size, and price, along with corresponding getters and setters. The 'Solution' class reads input for multiple shoes, stores them in an array, and allows searching for a shoe by type, printing the details if found. If no shoe of the specified type is present, it outputs 'No Shoe present'.

Uploaded by

araj71694
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Shoe

The document contains a Java program that defines a 'Shoe' class with attributes such as batch number, type, size, and price, along with corresponding getters and setters. The 'Solution' class reads input for multiple shoes, stores them in an array, and allows searching for a shoe by type, printing the details if found. If no shoe of the specified type is present, it outputs 'No Shoe present'.

Uploaded by

araj71694
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.io.

*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

class Shoe
{
private int batchnum;
private String type;
private int size;
private double price;

public Shoe(int batchnum,String type,int size,double price)


{
this.batchnum=batchnum;
this.type=type;
this.size=size;
this.price=price;
}

public int getBatchnum()


{
return batchnum;
}

public void setBatchnum(int batchnum)


{
this.batchnum=batchnum;
}

public String getType()


{
return type;
}

public void setType(String type)


{
this.type=type;
}

public int getSize()


{
return size;
}

public void setSize(int size)


{
this.size=size;
}

public double getPrice()


{
return price;
}

public void setPrice(double price)


{
this.price=price;
}

public class Solution


{
public static void main(String args[] ) throws Exception
{
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
Scanner sc=new Scanner(System.in);
int num=sc.nextInt();

Shoe[] shoes=new Shoe[num];

for(int i=0;i<num;i++)
{
int batchnum=sc.nextInt();
String type=sc.next();
int size=sc.nextInt();
int price=sc.nextInt();
shoes[i]=new Shoe(batchnum,type,size,price);
}

String searchType= sc.next();


Shoe result=GetShoebytype(shoes, searchType);

if(result != null)
{
System.out.println(result.getBatchnum());
System.out.println(result.getType());
System.out.println(result.getSize());
System.out.println(result.getPrice());
}
else
{
System.out.println("No Shoe present");
}
}

public static Shoe GetShoebytype(Shoe[] shoes,String type)


{
for(Shoe shoe : shoes)
{
if(shoe.getType().equalsIgnoreCase(type))
{
return shoe;
}
}
return null;
}
}

You might also like