CTS JAVA Complete Solution
CTS JAVA Complete Solution
CTS JAVA Complete Solution
2) Student Details
import java.util.Scanner;
System.out.println("Applicant name");
String str=sc.nextLine();
int num=sc.nextInt();
int num1=sc.nextInt();
float num2=sc.nextFloat();
int num3=sc.nextInt();
System.out.println("Total possible marks in SSLC");
int num4=sc.nextInt();
System.out.println("Gender");
char ch=sc.next().charAt(0);
3)Runs Scored
import java.util.Scanner;
import java.util.*;
System.out.println("Runs scored");
double a=sc.nextDouble();
System.out.println("Boundaries scored");
double b=sc.nextDouble();
System.out.println("Sixers scored");
double c=sc.nextDouble();
double p= ((a-run)/a)*100;
double h=Math.round(p);
4)Population census
import java.util.Scanner;
int p = sc.nextInt();
int q = sc.nextInt();
year"+(((((q-p)*100/p)))/10));
}
import java.util.Scanner;
String s = sc.nextLine();
switch(s)
case "A" :
break;
case "B" :
break;
case "C" :
break;
case "D" :
case "E" :
break;
default:
sc.close();
6)Ludo King
import java.util.Scanner;
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
else
sc.close();
7)Resort Booking
import java.util.Scanner;
String s = sc.nextLine();
int i = 0;
while(s.charAt(i) != ':')
i++;
}
i++;
if((s.charAt(i)-'0') < 0)
i = 0;
while(s.charAt(i) != ':')
System.out.print(s.charAt(i));
i++;
i++;
"+((((s.charAt(i)-'0')1000 + (s.charAt(i+2)-'0')*650))(s.charAt(i+4)-'0')));
import java.util.Scanner;
import java.util.*;
int t = sc.nextInt();
if(t<=1){
System.out.println("Invalid input");
System.exit(0);
int m= t;
float sum=0;
for(int k=0;k<t;k++){
sum=0;
String str=sc.next();
int n =arr1.length;
arr[0]=Float.parseFloat(arr1[1]);
arr[1]=Float.parseFloat(arr1[2]);
arr[2]=Float.parseFloat(arr1[3]);
arr[3]=Float.parseFloat(arr1[4]);
System.out.println("Invalid number");
return;
}
sum = arr[0]+arr[1]+arr[2]+arr[3];
hm.put(sum,arr1[0]);
for(int i=0;i<t;i++){
if(sum<min_sum)
min_sum=sum;
if(minKey.equals("Prince")){
}else{
9)Alphabetical order
import java.util.*;
Arrays.sort(arr);
return String.valueOf(arr);
int n =arr1.length;
for(int j=0;j<n;j++){
for(char c : chars){
if(Character.isDigit(c)){
return;
for(int i=0;i<n;i++){
arr[i]=sortString(arr1[i]);
System.out.print(arr[i]+" ");
10)Sum of Max
import java.util.*;
int n = sc.nextInt();
if(n<=1 || n%2!=0){
return;
for(int i =0;i<n;i++){
arr[i]=sc.nextInt();
Arrays.sort(arr);
for(int d=arr.length-1;d>=0;d--){
all.add(arr[d]);
for(int j=0;j<n;j++){
al.add(arr[j] + all.get(j));
11)Incredible toys
import java.util.regex.Matcher;
import java.util.regex.Pattern;
this.customerId=customerId;
this.customerName=customerName;
this.phoneNumber=phoneNumber;
this.emailId=emailId;
this.toyType=toyType;
this.price=price;
return this.customerId;
{
this.customerId=customerId;
return this.customerName;
this.customerName=customerName;
return this.phoneNumber;
this.phoneNumber=phoneNumber;
return this.emailId;
this.emailId=emailId;
}
return toyType;
this.toyType=toyType;
return this.price;
this.price=price;
String customerId=getCustomerId();
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(customerId);
if(m.find())
{
return true;
return false;
int dis=0;
toyType=toyType.toLowerCase();
switch(toyType)
case "softtoys":
dis=5;
break;
case "fidgettoys":
dis=10;
break;
case "sensorytoys":
dis=15;
break;
case "puzzles":
dis=20;
break;
return (price-(price*dis/100));
}
}
------------------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
String customerId=sc.next();
String customerName=sc.next();
long phoneNumber=sc.nextLong();
String emailId=sc.next();
System.out.println("Enter type");
String toyType=sc.next();
System.out.println("Enter Price");
CustomerDetails cd=new
CustomerDetails(customerId,customerName,phoneNumber,emailId,toyType,price);
if(cd.validateCustomerId())
double amount=cd.calculateDiscount();
else{
this.carId=carId;
this.modelNumber=modelNumber;
this.colour=colour;
this.transmissionType=transmissionType;
this.fuelType=fuelType;
this.engineType=engineType;
this.bodyType=bodyType;
this.engineDisplacement=engineDisplacement;
this.bootSpace=bootSpace;
this.seatCapacity=seatCapacity;
return this.carId;
this.carId=carId;
return this.modelNumber;
this.modelNumber=modelNumber;
}
public String getColour()
return this.colour;
this.colour=colour;
return this.transmissionType;
this.transmissionType=transmissionType;
return this.fuelType;
this.fuelType=fuelType;
return this.engineType;
this.engineType=engineType;
return this.bodyType;
this.bodyType=bodyType;
return this.engineDisplacement;
this.engineDisplacement=engineDisplacement;
{
return this.bootSpace;
this.bootSpace=bootSpace;
return this.seatCapacity;
this.seatCapacity=seatCapacity;
------------------------------------------------------------------------------------------------------------------------------------------
Carutility.java
import java.util.Scanner;
Car[] carObj=createCarDetails();
int n=carObj.length;
for(int i=0;i<n;i++)
System.out.println("Car Id "+carObj[i].getCarId());
System.out.println("Colour "+carObj[i].getColour());
int n=sc.nextInt();
Car[] carObj=new Car[n];
for(int i=0;i<n;i++)
String carId=sc.nextLine();
carId = sc.nextLine();
String modelNumber=sc.nextLine();
System.out.println("Enter Colour");
String colour=sc.nextLine();
String transmissionType=sc.nextLine();
String fuelType=sc.nextLine();
String engineType=sc.nextLine();
String bodyType=sc.nextLine();
int engineDisplacement=sc.nextInt();
int bootSpace=sc.nextInt();
int seatCapacity=sc.nextInt();
return carObj;
13)Electricity board
this.customerId=customerId;
this.customerName=customerName;
this.phoneNumber=phoneNumber;
this.city=city;
this.unitsConsumed=unitsConsumed;
this.costPerUnit=costPerUnit;
return customerId;
return customerName;
this.customerName=customerName;
return phoneNumber;
this.phoneNumber=phoneNumber;
return city;
this.city=city;
return unitsConsumed;
this.unitsConsumed=unitsConsumed;
}
return costPerUnit;
this.costPerUnit=costPerUnit;
return amount;
------------------------------------------------------------------------------------------------------------------------------------------
import java.util.*;
String s2 = scanner.nextLine();
System.out.println("Enter City");
String city = scanner.next();
double cu=scanner.nextDouble();
double cuu=scanner.nextDouble();
String.format("%.2f",c1.calculateElectricityBill()));
14)Movie Static
import java.util.Scanner;
System.out.println("Enter no of bookings");
ticket.setAvailableTickets(availableTickets);
ticket.setTicketid(ticketId);
ticket.setPrice(price);
if(cost>0){
else{
return;
}if(ticket.getAvailableTickets()==0){
System.out.println("House full");
}else{
}}
------------------------------------------------------------------------------------------------------------------------------------------
return ticketid;
this.ticketid = ticketid;
return price;
this.price = price;
return availableTickets;
if (availableTickets > 0) {
Ticket.availableTickets = availableTickets;
}else{
Ticket.availableTickets=-1;
availableTickets -= nooftickets;
} else {
return -1;
15)game card
this.cardId = cardId;
this.holderName = holderName;
this.balancePoints = balancePoints;
return true;
} else {
return false;
return cardId;
this.cardId = cardId;
return holderName;
this.holderName = holderName;
}
public int getBalancePoints() {
return balancePoints;
this.balancePoints = balancePoints;
import java.util.Scanner;
do{
balancePoints = sc.nextInt();
continue;
else
break;
while(true);
return getPointUsage();
return pointUsage;
}
public static void main(String[] arg)
CardPoints cp = gameCardDetails.getCardDetails();
cp.withdrawPoints(points);
return doctorId;
this.doctorId = doctorId;
this.doctorName = doctorName;
return specialization;
this.specialization = specialization;
return hospital;
this.hospital = hospital;
this.doctorId = doctorId;
this.doctorName = doctorName;
this.specialization = specialization;
this.hospital = hospital;
------------------------------------------------------------------------------------------------------------------------------------------
public class Hospital {
private String hospitalName;
return hospitalName;
return contactNumber;
return city;
this.hospitalName = hospitalName;
this.contactNumber = contactNumber;
this.city = city;
this.hospitalName = hospitalName;
this.contactNumber = contactNumber;
this.city = city;
}
---------------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
Doctor doc=createDoctorDetails();
System.out.println("Doctor id:"+doc.getDoctorId());
System.out.println("Doctor name:"+doc.getDoctorName());
System.out.println("Specialization:"+doc.getSpecialization());
System.out.println("Hospital name:"+doc.getHospital().getHospitalName());
System.out.println("Contact Number:"+doc.getHospital().getContactNumber());
System.out.println("City:"+doc.getHospital().getCity());
String hName=sc.nextLine();
long cNo=sc.nextLong();
sc.nextLine();
System.out.println("Enter City");
String city=sc.nextLine();
String id=sc.nextLine();
String dName=sc.nextLine();
System.out.println("Enter Specialization");
return doc;
17)Disney
return noOfDays;
return foodType;
this.foodType = foodType;
this.noOfDays=noOfDays;
this.foodType=foodType;
if(this.foodType.equals("NonVeg")){
return 0.0;
---------------------------------------------------------------------------------------------------------------------------------------
this.noOfHours=noOfHours;
this.guide=guide;
if(this.guide.equals("Yes") || this.guide.equals("yes")){
return 0.0;
---------------------------------------------------------------------------------------------------------------------------------------
this.customerName = customerName;
this.cityName = cityName;
this.phoneNumber = phoneNumber;
this.noOfPeople = noOfPeople;
return customerName;
this.customerName = customerName;
return cityName;
this.cityName = cityName;
return phoneNumber;
this.phoneNumber = phoneNumber;
}
return noOfPeople;
this.noOfPeople = noOfPeople;
---------------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
);
switch (option){
case 1:
customerName,
cityName,
phoneNumber,
noOfPeople,
noOfDays,
foodType);
System.out.println("Your booking has been confirmed pay Rs."+BHB.calculateTotalAmount());
break;
case 2:
customerName,
cityName,
phoneNumber,
noOfPeople,
noOfHours,
guide
);
break;
}
18)College Fees
public DayScholar(int studentId, String studentName, String department, String gender, String category,
double collegeFee,int busNumber,float distance) {
this.busNumber=busNumber;
this.distance=distance;
return busNumber;
return distance;
this.distance = distance;
int busFees=0;
busFees=28000;
busFees=20000;
busFees=6000;
if(this.collegeFee>0){
return (double)(this.collegeFee+busFees);
return 0;
-------------------------------------------------------------------------------------------------------------------------------------
public Student(int studentId, String studentName, String department, String gender, String category,
double collegeFee) {
this.studentId = studentId;
this.studentName = studentName;
this.department = department;
this.gender = gender;
this.category = category;
this.collegeFee = collegeFee;
return studentId;
this.studentId = studentId;
}
public String getStudentName() {
return studentName;
this.studentName = studentName;
return department;
this.department = department;
}
public String getGender() {
return gender;
this.gender = gender;
return category;
this.category = category;
}
public double getCollegeFee() {
return collegeFee;
this.collegeFee = collegeFee;
-------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
System.out.println("Enter gender");
System.out.println("Enter category");
switch(category){
case "DayScholar":
studentId,
studentName,
department,
gender,
category,
collegeFee,
busNumber,
distance
);
break;
case "Hosteller":
studentId,
studentName,
department,
gender,
category,
collegeFee,
roomNumber,
blockName,
roomType
);
break;
}
}
------------------------------------------------------------------------------------------------------------------------------------
public Hosteller(int studentId, String studentName, String department, String gender, String category,
double collegeFee, int roomNumber, char blockName, String roomType) {
this.roomNumber=roomNumber;
this.blockName=blockName;
this.roomType=roomType;
}
@Override
int hostelFee=0,roomTypeAmount=0;
switch (this.blockName){
case 'A':
hostelFee=60000;
if(this.roomType.equals("AC")){
roomTypeAmount=8000;
break;
case 'B':
hostelFee=50000;
if(this.roomType.equals("AC")){
roomTypeAmount=5000;
break;
case 'C':
hostelFee=40000;
if(this.roomType.equals("AC")){
roomTypeAmount=2500;
break;
}
if(this.roomType.equals("AC")){
return (double)(this.collegeFee+hostelFee+roomTypeAmount);
}else if(!this.roomType.equals("AC")){
return (double)(this.collegeFee+hostelFee);
return 0.0;
19)Departmental store
---------------------------------------------------------------------------------------------------------------------------------------
return customerName;
this.customerName = customerName;
return phoneNumber;
this.phoneNumber = phoneNumber;
return streetName;
this.streetName = streetName;
this.billAmount = billAmount;
return distance;
this.distance = distance;
int distance) {
this.customerName = customerName;
this.phoneNumber = phoneNumber;
this.streetName = streetName;
this.billAmount = billAmount;
this.distance = distance;
double billAmount=this.getBillAmount();
if(billAmount<250)
{
return 0;
else
return (billAmount/10);
double distance=this.getDistance();
if(distance>=25)
return (distance*8);
return (distance*5);
else
return (distance*2);
}
}
import java.util.Scanner;
String name=sc.nextLine();
String phone=sc.nextLine();
String street=sc.nextLine();
double amount=sc.nextDouble();
sc.nextLine();
int distance=sc.nextInt();
double delivery=obj.deliveryCharge();
20)Viveks
return beroType;
this.beroType = beroType;
return beroColour;
this.beroColour = beroColour;
}
return price;
this.price = price;
this.beroType = beroType;
this.beroColour = beroColour;
return customerName;
this.customerName = customerName;
this.phoneNumber = phoneNumber;
return address;
this.address = address;
super();
this.customerName = customerName;
this.phoneNumber = phoneNumber;
this.address = address;
---------------------------------------------------------------------------------------------------------------------------------------
double price=bObj.getPrice();
double discount=0;
discount=price*0.1;
discount=price*0.15;
return discount;
--------------------------------------------------------------------------------------------------------------------------------------
return beroHeight;
this.beroHeight = beroHeight;
this.beroHeight = height;
@Override
int height=this.getBeroHeight();
if(height==3)
this.setPrice(5000);
else if(height==5)
this.setPrice(8000);
else if(height==7)
this.setPrice(10000);
-----------------------------------------------------------------------------------------------------------------------------------------
return woodType;
this.woodType = woodType;
super(beroType, beroColour);
this.woodType = woodType;
@Override
String type=this.getWoodType();
if(type.equals("Ply Wood"))
this.setPrice(15000);
this.setPrice(12000);
}
else if(type.equals("Engineered Wood"))
this.setPrice(10000);
---------------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
String name=sc.nextLine();
long phone=sc.nextLong();
sc.nextLine();
System.out.println("Enter Address");
String address=sc.nextLine();
String type=sc.nextLine();
String colour=sc.nextLine();
double price=0;
Discount d=new Discount();
Bero obj;
if(type.equals("Steel Bero"))
int height=sc.nextInt();
sc.nextLine();
obj=new SteelBero(type,colour,height);
obj.calculatePrice();
price=obj.getPrice()- d.calculateDiscount(obj);
String wtype=sc.nextLine();
obj=new WoodenBero(type,colour,wtype);
obj.calculatePrice();
price=obj.getPrice()- d.calculateDiscount(obj);
System.out.printf("%.2f",price);
}
21)Campus radio
super(message);
-------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
try{
vd.validateStation(freq);
}catch(StationNotAvailableException e){
--------------------------------------------------------------------------------------------------------------------------------
flag = true;
else{
return flag;
22)String extract
import java.util.Scanner;
public class Main {
int s = sc.nextInt();
int e = sc.nextInt();
System.out.println(stringExtraction.extractString(sentence,s,e));
try{
}else if(number1>number2){
else{
stringBuilder.append(sentence.charAt(i));
stringBuilder.append(".");
stringBuilder.append("Extraction of String using the given index is not possible.Thanks for using the
application. ");
}finally {
return stringBuilder.toString();
}
}
23)Vega Cricket
import java.util.*;
import java.util.stream.*;
M.setPlayerMap(playerMap);
int z=0;
while(z!=3)
System.out.println("Select an option:");
System.out.println("2.Display");
System.out.println("3.Exit");
z=sc.nextInt();
String name="";
int score=0;
if(z==1)
{
System.out.println("Enter the player name");
name=sc.next();
score=sc.nextInt();
M.addPlayerScore(name,score);
else if(z==2)
Map<String,Integer> playermap=M.getPlayerMap();
Stream<Map.Entry<String,Integer>> playerStream=playermap.entrySet().stream();
int max_score=M.maximumScore(playerStream);
if(max_score==0)
else
else{
break;
}
}
-----------------------------------------------------------------------------------------------------------------------------------
import java.util.Map;
import java.util.*;
import java.util.stream.Stream;
import java.util.stream.Collectors;
return playerMap;
this.playerMap = playerMap;
playerMap.put(playerName,score);
//Collections.sort(hashList, Collections.reverseOrder());
List<Integer> l=playerStream.map(Map.Entry::getValue).collect(Collectors.toList());
if(l.isEmpty())
return 0;
else{
int m=Collections.max(l);
System.out.println(m);
return m;
24)Top tier
import java.util.*;
int n = Integer.parseInt(sc.nextLine());
vh.setVehicleMap(new HashMap<String,Double>());
for(int i=0;i<n;i++){
String veh=sc.nextLine();
double price=Double.parseDouble(sc.nextLine());
vh.addVehiclePriceDetails(veh,price);
Map<String,Double> polmap=vh.getVehicleMap();
char choice;
do
if(vh.calculateCostAfterDiscount(search)!=0){
}else{
if((choice=='n')||(choice=='N')){
break;
while((choice=='y')||(choice=='Y'));
-----------------------------------------------------------------------------------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
return vehicleMap;
this.vehicleMap = vehicleMap;
// This method should add the vehicleName as key and the price of the
// vehicle as value into a Map
vehicleMap.put(vehicleName,price);
// This method should calculate the discount and return the selling price
if(vehicleMap.containsKey(vehicleName)){
double discount=0;
double sp=0;
double h=vehicleMap.get(vehicleName);
if(vehicleName.contains("TVS")){
discount=10;
}else if(vehicleName.contains("Honda")){
discount=5;
}else if(vehicleName.contains("Yamaha")){
discount=7;
sp= h*(100-discount)/100;
return sp;}
else{
return 0;
25)Global Hospital
import java.util.Scanner;
import java.util.stream.Stream;
import java.util.List;
int n = Integer.parseInt(sc.nextLine());
for(int i=0;i<n;i++)
Strings[i] = donor;
}
if(finalResult.size() != 0)
finalResult.forEach(s ->{System.out.println(s);});
else
--------------------------------------------------------------------------------------------------------------------------------------
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;
import java.util.List;
for(int i=0;i<details.length;i++)
long mb = Long.parseLong(splitString[3]);
temp.add(new Donor(splitString[0],splitString[1],splitString[2],mb));
return temp;
return donorDetails.stream();
Collections.sort(result);
return result;
this.donorId = id;
this.donorName = name;
this.bloodGroup = group;
this.mobileNumber = mn;
return donorId;
}
public void setDonorId(String donorId) {
this.donorId = donorId;
return donorName;
this.donorName = donorName;
return bloodGroup;
this.bloodGroup = bloodGroup;
return mobileNumber;
this.mobileNumber = mobileNumber;
}
26)Hyper super market
import java.util.Scanner;
import java.util.stream.Stream;
import java.util.*;
int num = 0;
while(num != 3){
num = sc.nextInt();
if(num == 1){
String name=sc.next();
vege.setVegetableName(name);
vege.setWeightInKgs(weight);
vege.setPricePerKg(price);
m.addToBasket(vege);
else if(num==2)
List<VegetableBasket>vegeBasketList =m.getVegetableBasketList();
if(vegeBasketList.size()==0)
else{
Stream<VegetableBasket>vegetableBasketStream = vegeBasketList.stream();
return vegetableName;
this.vegetableName = vegetableName;
return weightInKgs;
this.weightInKgs = weightInKgs;
return pricePerKg;
this.pricePerKg = pricePerKg;
}
}
import java.util.List;
import java.util.stream.Stream;
import java.util.*;
import java.util.stream.Collectors;
import java.util.function.Function;
return this.vegetableBasketList;
this.vegetableBasketList = vegetableBasketList;
vge.add(fbObj);
setVegetableBasketList(vge);
}
public static int calculateBill(Stream<VegetableBasket> vegetableBasketStream) {
int amount=0;
amount=amount+(entry.getKey()*entry.getValue());
return amount;
27)Food cart
import java.util.Scanner;
int flag=1;
try {
while (myReader.hasNextLine())
if(lineFromFile.contains(Value))
// System.out.println("customer.txt");
System.out.println(lineFromFile);
flag=0;
break;
if (flag==1)
myReader.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
Robert:7329102839:Pizza:2:2000
Advaith:8329103940:BBQ:1:350
Thanos:9762453210:Burger:4:570
Lewi:9036524133:Pizza:2:633
Albert:6852416398:BBQ:6:2000
Rahul:6663410275:Burger:4:451
Robert:8763957410:Pizza:2:1026
Jerold:9096741023:BBQ:2:457
Virat:8078451296:Burger:4:600
Dhoni:9363021245:Pizza:2:974
Praga:7685963210:BBQ:4:540
Aravind:6241053689:Burger:4:570
Praveen:8956451203:Pizza:2:3201
Issac:6410258963:BBQ:1:2000
Manish:9512023654:Burger:4:941
Ranjith:7456899874:BBQ:1:720
Akash:6352987451:Burger:4:570
Rakesh:8090461375:Pizza:8:610
Anees:9080708090:BBQ:7:350
Alex:6501200332:Burger:4:340
28)Fuel
@FunctionalInterface
import java.util.*;
{ double price=0;
fuelName=fuelName.toLowerCase();
if(fuelName.equals("petrol"))
price=litres*90.4;
else if(fuelName.equals("diesel"))
price=litres*86.8;
return price;
};
String s=sc.next();
System.out.println("Enter litres");
double l=sc.nextDouble();
FuelCalc f=generateRate();
double p=f.calculateFuel(s,l);
29)College account
import java.util.Scanner;
if (courseType.equalsIgnoreCase("regular")) {
return regularFee;
} else if (courseType.equalsIgnoreCase("selfFinance")) {
} else {
return 0;
}
};
System.out.println("Enter no of semesters");
System.out.println("Course type");
System.out.println("Fees Receipt");
}
29)Water distributor
return distributorName;
this.distributorName = distributorName;
return volume;
this.volume = volume;
return count;
this.count = count;
this.distributorName = distributorName;
this.volume = volume;
this.count = count;
----------------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner;
return(Container containerobj)->
{ double dp=0;
if(containerobj.count>=100){
if(containerobj.volume==10)
dp=(20*containerobj.count)-(.1*containerobj.count*20);
else if(containerobj.volume==25)
dp=50*containerobj.count-(.15*containerobj.count*50);
else{
if(containerobj.volume==10)
dp=(containerobj.count*20);
else if(containerobj.volume==25)
dp= (containerobj.count*50);
return dp;
};
String s=sc.next();
int d=sc.nextInt();
int h=sc.nextInt();
if(d==25 || d==10)
DiscountInfo k=generateBillAmount();
}
else
System.out.println("There is no Discount");
31)Book sale
return bookName;
this.bookName = bookName;
return authorName;
return bookCost;
this.bookCost = bookCost;
@Override
import java.util.List;
import java.util.stream.Stream;
import java.util.*;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.Collections;
return this.bookList;
this.bookList = bookList;
return getBookList().stream();
Double MUTIPLY_ELEMENT=0.90;
MUTIPLY_ELEMENT).collect(Collectors.toList());
return answer;
---------------------------------------------------------------------------------------------------------------------------------
import java.util.*;
import java.util.stream.Stream;
{
Scanner sc = new Scanner(System.in);
int N=sc.nextInt();
if(N>0)
sc.nextLine();
for(int i=0;i<N;i++)
arr[i]=sc.nextLine();
for(int i=0;i<N;i++)
String[] word=arr[i].split(":");
b.setAuthorName(word[1]);
b.setBookName(word[0]);
double v=Double.parseDouble(word[2]);
b.setBookCost(v);
list.add(b);
B.setBookList(list);
Stream<Book> stream=B.listToStream();
List<Double> answer=B.calculateBookDiscount(stream);
for(int i=0;i<N;i++)
System.out.println(answer.get(i));
else{
System.out.println("Invalid Entry");
32)Association contest
return id;
}
this.id = id;
return name;
this.name = name;
return address;
this.address = address;
------------------------------------------------------------------------------------------------------------------------------------
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Stream;
import java.util.stream.Collectors;
return this.ContestList;
this.ContestList=ContestList;
return list.stream();
Map<String,String>file = stream1.collect(Collectors.toMap(Contestant-
>Contestant.getId(),Contestant->Contestant.getName()));
String s=Character.toString(varString);
if(entry.getValue().toLowerCase().startsWith(s.toLowerCase()))
{
l.add(entry.getKey());
return l;
import java.util.*;
import java.util.stream.Stream;
int N=sc.nextInt();
if(N>0)
for(int i=0;i<N;i++)
String arr=sc.next();
String[] word=arr.split("/");
String id=word[0];
String place=word[2];
c.setId(id);
c.setName(name);
c.setAddress(place);
ContestList.add(c);
C.setContestList(ContestList);
Stream<Contestant>stream = C.changeToStream();
List list=C.searchFromDetails(stream,alpha);
if(list.size()!=0)
for(int i=0;i<N;i++)
if(list.contains(Contest.get(i).getId()))
else{
else{
System.out.println("Invalid");
}
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
int a = Integer.parseInt(sc.nextLine());
if (a<=0){
System.out.println("Invalid");
else{
x[j] =sc.nextLine();
String[] p = x[j].split("/");
cd.setVehicleHolderName(p[1]);
cd.setVehicleHolderAddress(p[2]);
clm.add(cd);
obj.setVehicleList(clm);
int uh = Integer.parseInt(sc.nextLine());
if (ans.isEmpty()){
else{
}
}
-----------------------------------------------------------------------------------------------------------------------------------
return vehicleNo;
this.vehicleNo = vehicleNo;
return vehicleHolderName;
this.vehicleHolderName = vehicleHolderName;
this.vehicleHolderAddress = vehicleHolderAddress;
@Override
------------------------------------------------------------------------------------------------------------------------------
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
return vehicleList;
Stream<Vehicle> w =vehicleList.stream();
return w;
List<Vehicle> shot=stream1.filter(x-
>String.valueOf(x.getVehicleNo()).length()>=length).sorted(Comparator.comparingInt(Vehicle::getVehicl
eNo)).collect(Collectors.toList());
return shot;
super();
public Book(String bookId, String bookName, String bookType, String bookCategory, String
bookEdition) {
super();
this.bookId = bookId;
this.bookName = bookName;
this.bookType = bookType;
this.bookCategory = bookCategory;
this.bookEdition = bookEdition;
return bookId;
this.bookId = bookId;
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
return bookType;
this.bookType = bookType;
return bookEdition;
this.bookEdition = bookEdition;
return bookCategory;
this.bookCategory = bookCategory;
}
------------------------------------------------------------------------------------------------------------------------------------
import java.util.ArrayList;
import java.util.List;
return bookList;
return searchbookName;
this.bookList=a;
this.searchbookName=x;
this.counter=counter;
if (obj.getBookType().compareToIgnoreCase("Engineering")==0){
bookList.add(obj);
else{
int count=0;
for(int j=0;j<bookList.size();j++){
if (bookList.get(j).getBookName().compareToIgnoreCase(searchbookName)==0){
count=count+1;
}
if (count==0) {
else {
----------------------------------------------------------------------------------------------------------------------------------
String s;
super(s);
}
}
------------------------------------------------------------------------------------------------------------------------------------------
import java.util.ArrayList;
import java.util.List;
int a = Integer.parseInt(sc.nextLine());
x[j] =sc.nextLine();
String[] p = x[j].split("/");
cd.setBookId(p[0]);
cd.setBookName(p[1]);
cd.setBookType(p[2]);
cd.setBookCategory(p[3]);
cd.setBookEdition(p[4]);
try{
ans.toValidateBookType(cd);
clm.add(cd);
catch(InvalidBookException e){
flag=true;
System.out.println(e.getMessage());
if (flag==false){
ans.setBookList(clm);
for(int y=0;y<clm.size();y++){
System.out.println("bookId="+clm.get(y).getBookId()+",
bookName="+clm.get(y).getBookName()+", bookType="+clm.get(y).getBookType());
String hh = sc.nextLine();
ans.setSearchbookName(hh);
myThread.run();
}
}