ZeeZee Bank
[Link]
public class Account {
private long accountNumber;
private double balanceAmount;
public Account(long accountNumber, double balanceAmount) {
[Link] = accountNumber;
[Link] = balanceAmount;
}
public long getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(long accountNumber) {
[Link] = accountNumber;
}
public double getBalanceAmount() {
return balanceAmount;
}
public void setBalanceAmount(double balanceAmount) {
[Link] = balanceAmount;
}
public void deposit(double depositAmount) {
balanceAmount += depositAmount;
}
public boolean withdraw(double withdrawAmount) {
if (withdrawAmount <= balanceAmount) {
balanceAmount -= withdrawAmount;
return true;
}
return false;
}
}
[Link]
import [Link];
import [Link];
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
DecimalFormat decimalFormat = new DecimalFormat("0.00");
[Link]("Enter the account number:");
long accountNumber = [Link]();
[Link]("Enter initial balance:");
double balanceAmount = [Link]();
Account account = new Account(accountNumber, balanceAmount);
[Link]("Enter the amount to be deposited:");
double depositAmount = [Link]();
[Link](depositAmount);
double availableBalance = [Link]();
[Link]("Available balance is:" + [Link](availableBalance));
[Link]("Enter the amount to be withdrawn:");
double withdrawAmount = [Link]();
boolean isWithdrawn = [Link](withdrawAmount);
availableBalance = [Link]();
if (!isWithdrawn) {
[Link]("Insufficient balance");
}
[Link]("Available balance is:" + [Link](availableBalance));
}
}
Numerology number
[Link]
import [Link];
public class Main {
private static int getSum(long num) {
char[] chars = [Link](num).toCharArray();
int sum = 0;
for (char ch : chars) {
sum += [Link](ch, 10);
}
return sum;
}
private static int getNumerology(long num) {
String string = [Link](num);
while ([Link]() != 1) {
string = [Link](getSum([Link](string)));
}
return [Link](string);
}
private static int getOddCount(long num) {
int oddCount = 0;
for (char ch : [Link](num).toCharArray()) {
if ([Link](ch, 10) % 2 != 0) {
++oddCount;
}
}
return oddCount;
}
private static int getEvenCount(long num) {
int evenCount = 0;
for (char ch : [Link](num).toCharArray()) {
if ([Link](ch, 10) % 2 == 0) {
++evenCount;
}
}
return evenCount;
}
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter the number");
long num = [Link]();
[Link]("Sum of digits");
[Link](getSum(num));
[Link]("Numerology number");
[Link](getNumerology(num));
[Link]("Number of odd numbers");
[Link](getOddCount(num));
[Link]("Number of even numbers");
[Link](getEvenCount(num));
}
}
Substitution Cipher Technique
[Link]
import [Link].*;
public class Main {
public static void main(String[] args) {
StringBuilder stringBuilder = new StringBuilder();
Scanner scanner = new Scanner([Link]);
[Link]("Enter the encrypted text:");
String text = [Link]();
char[] chars = [Link]();
boolean flag = false;
for (char ch : chars) {
if ([Link](ch)) {
flag = true;
if ([Link](ch)) {
int sub = (int) ch - 7;
if (sub < 97) {
ch = (char) (122 - (97 - sub) + 1);
} else {
ch = (char) sub;
}
} else if ([Link](ch)) {
int sub = (int) ch - 7;
if (sub < 65) {
ch = (char) (90 - (65 - sub) + 1);
} else {
ch = (char) sub;
}
}
[Link](ch);
} else if ([Link](ch)) {
[Link](ch);
}
}
if (flag) {
[Link]("Decrypted text:");
[Link]([Link]());
} else {
[Link]("No hidden message");
}
}
}
Bank Account - Interface
[Link]
public class Account {
private String accountNumber;
private String customerName;
private double balance;
public Account(String accountNumber, String customerName, double balance) {
[Link] = accountNumber;
[Link] = customerName;
[Link] = balance;
}
public String getAccountNumber() {
return accountNumber;
}
public void setAccountNumber(String accountNumber) {
[Link] = accountNumber;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
[Link] = customerName;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
[Link] = balance;
}
}
[Link]
public class CurrentAccount extends Account implements MaintenanceCharge {
public CurrentAccount(String accountNumber, String customerName, double balance) {
super(accountNumber, customerName, balance);
}
@Override
public float calculateMaintenanceCharge(float noOfYears) {
return (100.0f + noOfYears) + 200.0f;
}
}
[Link]
public interface MaintenanceCharge {
float calculateMaintenanceCharge(float noOfYears);
}
[Link]
public class SavingsAccount extends Account implements MaintenanceCharge {
public SavingsAccount(String accountNumber, String customerName, double balance) {
super(accountNumber, customerName, balance);
}
@Override
public float calculateMaintenanceCharge(float noOfYears) {
return (50.0f * noOfYears) + 50.0f;
}
}
[Link]
import [Link];
import [Link];
public class UserInterface {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
DecimalFormat decimalFormat = new DecimalFormat("0.0");
[Link]("1. Savings Account");
[Link]("2. Current Account");
[Link]("Enter your choice:");
int choice = [Link]();
[Link]("Enter the Account number");
String accountNumber = [Link]();
[Link]("Enter the Customer Name");
String customerName = [Link]();
[Link]("Enter the Balance amount");
double balance = [Link]();
[Link]("Enter the number of years");
int noOfYears = [Link]();
[Link]("Customer Name " + customerName);
[Link]("Account Number " + accountNumber);
[Link]("Account Balance " + [Link](balance));
switch (choice) {
case 1: {
SavingsAccount savingsAccount = new SavingsAccount(accountNumber,
customerName, balance);
[Link]("Maintenance Charge for Savings Account is Rs " +
[Link]([Link](noOfYears)));
break;
}
case 2: {
CurrentAccount currentAccount = new CurrentAccount(accountNumber,
customerName, balance);
[Link]("Maintenance Charge for Current Account is Rs " +
[Link]([Link](noOfYears)));
}
}
}
}
Batting Average
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
public class UserInterface {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
Player player = new Player();
[Link](new ArrayList<>());
boolean flag = true;
while (flag) {
[Link]("1. Add Runs Scored");
[Link]("2. Calculate average runs scored");
[Link]("3. Exit");
[Link]("Enter your choice");
int choice = [Link]();
switch (choice) {
case 1: {
[Link]("Enter the runs scored");
int score = [Link]();
[Link](score);
break;
}
case 2: {
[Link]("Average runs secured");
[Link]([Link]());
break;
}
case 3: {
[Link]("Thank you for use the application");
flag = false;
break;
}
}
}
}
}
[Link]
package [Link];
import [Link];
public class Player {
private List<Integer> scoreList;
public List<Integer> getScoreList() {
return scoreList;
}
public void setScoreList(List<Integer> scoreList) {
[Link] = scoreList;
}
public double getAverageRunScored() {
if ([Link]()) {
return 0.0;
}
int size = [Link]();
int totalScore = 0;
for (int score : scoreList) {
totalScore += score;
}
return (double) totalScore / (double) size;
}
public void addScoreDetails(int score) {
[Link](score);
}
}
Grade Calculation
[Link]
import [Link];
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter the number of Threads:");
int n = [Link]();
GradeCalculator[] gradeCalculators = new GradeCalculator[n];
Thread[] threads = new Thread[n];
for (int i = 0; i < n; ++i) {
[Link]("Enter the String:");
String string = [Link]();
String[] strings = [Link](":");
int[] marks = new int[5];
String studName = strings[0];
for (int j = 1; j < 6; ++j) {
marks[j - 1] = [Link](strings[j]);
}
gradeCalculators[i] = new GradeCalculator(studName, marks);
threads[i] = new Thread(gradeCalculators[i]);
threads[i].start();
threads[i].interrupt();
}
for (int i = 0; i < n; ++i) {
[Link](gradeCalculators[i].getStudName() + ":" +
gradeCalculators[i].getResult());
}
}
}
[Link]
public class GradeCalculator extends Thread {
private String studName;
private char result;
private int[] marks;
public GradeCalculator(String studName, int[] marks) {
[Link] = studName;
[Link] = marks;
}
public String getStudName() {
return studName;
}
public void setStudName(String studName) {
[Link] = studName;
}
public char getResult() {
return result;
}
public void setResult(char result) {
[Link] = result;
}
public int[] getMarks() {
return marks;
}
public void setMarks(int[] marks) {
[Link] = marks;
}
@Override
public void run() {
int totalMarks = 0;
for (int mark : marks) {
totalMarks += mark;
}
if (totalMarks <= 500 && totalMarks >= 400) {
result = 'A';
} else if (totalMarks < 400 && totalMarks >= 300) {
result = 'B';
} else if (totalMarks < 300 && totalMarks >= 200) {
result = 'C';
} else if (totalMarks < 200 && totalMarks >= 0) {
result = 'E';
}
}
}
Employees eligible for promotionCoding exercise
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
class Employee implements Comparable<Employee> {
private final String id;
private final LocalDate joiningDate;
private boolean isEligible;
public Employee(String id, LocalDate joiningDate) {
[Link] = id;
[Link] = joiningDate;
}
public void setIsEligible(LocalDate now) {
isEligible = [Link](now, [Link]) >= 5;
}
public boolean getIsEligible() {
return isEligible;
}
public String getId() {
return id;
}
@Override
public String toString() {
return id;
}
@Override
public int compareTo(Employee employee) {
return [Link]([Link]());
}
}
public class Main {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner([Link]);
DateTimeFormatter dateTimeFormatter = [Link]("dd/MM/yyyy");
LocalDate now = [Link]("01/01/2019", dateTimeFormatter);
int n = [Link]();
ArrayList<Employee> employees = new ArrayList<>();
[Link](1, 4).forEach(i -> {
String id = [Link]();
String joiningDateStr = [Link]();
try {
LocalDate joiningDate = [Link](joiningDateStr, dateTimeFormatter);
Employee employee = new Employee(id, joiningDate);
[Link](now);
[Link](employee);
} catch (Exception ignore) {
[Link]("Invalid date format");
[Link](0);
}
});
List<Employee> filteredEmployees =
[Link]().filter(Employee::getIsEligible).collect([Link]());
if ([Link]()) {
[Link]("No one is eligible");
} else {
[Link](filteredEmployees);
[Link]([Link]::println);
}
}
}
Check Number Type
[Link]
public interface NumberType {
boolean checkNumber(int num);
}
[Link]
import [Link];
public class NumberTypeUtility {
public static NumberType idOdd() {
return (num) -> num % 2 != 0;
}
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
int num = [Link]();
if (idOdd().checkNumber(num)) {
[Link](num + " is odd");
} else {
[Link](num + " is not odd");
}
}
}
Retrieve Flight details based on source and destination
[Link]
import [Link].*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner([Link]);
[Link]("Enter the source");
[Link]();
String source=[Link]();
[Link]("Enter the destination");
String dest=[Link]();
FlightManagementSystem obj=new FlightManagementSystem();
ArrayList<Flight> res=[Link](source,dest);
if(res!=null)
[Link](res);
else
[Link]("No flights available for the given source and destination");
}
}
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class DB {
private static Connection con = null;
private static Properties props = new Properties();
//ENSURE YOU DON'T CHANGE THE BELOW CODE WHEN YOU SUBMIT
public static Connection getConnection() throws ClassNotFoundException,
SQLException {
try{
FileInputStream fis = null;
fis = new FileInputStream("[Link]");
[Link](fis);
// load the Driver Class
[Link]([Link]("DB_DRIVER_CLASS"));
// create the connection now
con =
[Link]([Link]("DB_URL"),[Link]("DB_USERNA
ME"),[Link]("DB_PASSWORD"));
}
catch(IOException e){
[Link]();
}
return con;
}
}
[Link]
import [Link].*;
import [Link].*;
public class FlightManagementSystem{
public ArrayList<Flight> viewFlightsBySourceDestination(String source, String destination){
DB db=new DB();
ArrayList<Flight> list=new ArrayList<Flight>();
try{
int f=0;
Connection con=[Link]();
Statement st=[Link]();
String sql= "select * from Flight where source= '"+source+"' and destination=
'"+destination+"'";
ResultSet rs=[Link](sql);
while([Link]()){
f=1;
Flight x=new Flight([Link](1), [Link](2),[Link](3), [Link](4),
[Link](5));
[Link](x);
}
[Link]();
if(f==1)
return list;
else
return null;
}
catch(SQLException e){
[Link]("SQL Error. Contact Administrator.");
return null;
}
catch(Exception e){
[Link]("Exception. Contact Administrator.");
return null;
}
}
}
[Link]
public class Flight {
private int flightId;
private String source;
private String destination;
private int noOfSeats;
private double flightFare;
public int getFlightId() {
return flightId;
}
public void setFlightId(int flightId) {
[Link] = flightId;
}
public String getSource() {
return source;
}
public void setSource(String source) {
[Link] = source;
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
[Link] = destination;
}
public int getNoOfSeats() {
return noOfSeats;
}
public void setNoOfSeats(int noOfSeats) {
[Link] = noOfSeats;
}
public double getFlightFare() {
return flightFare;
}
public void setFlightFare(double flightFare) {
[Link] = flightFare;
}
public Flight(int flightId, String source, String destination,
int noOfSeats, double flightFare) {
super();
[Link] = flightId;
[Link] = source;
[Link] = destination;
[Link] = noOfSeats;
[Link] = flightFare;
}
public String toString(){
return ("Flight ID : "+getFlightId());
}
Perform Calculation
import [Link];
public class Calculator {
public static void main (String[] args) {
Scanner sc=new Scanner([Link]);
int a = [Link]();
int b= [Link]();
Calculate Perform_addition = performAddition();
Calculate Perform_subtraction = performSubtraction();
Calculate Perform_product = performProduct();
Calculate Perform_division = performDivision();
[Link]("The sum is "+Perform_addition.performCalculation(a,b));
[Link]("The difference is
"+Perform_subtraction.performCalculation(a,b));
[Link]("The product is "+Perform_product.performCalculation(a,b));
[Link]("The division value is
"+Perform_division.performCalculation(a,b));
public static Calculate performAddition(){
Calculate Perform_calculation = (int a,int b)->a+b;
return Perform_calculation;
}
public static Calculate performSubtraction(){
Calculate Perform_calculation = (int a,int b)->a-b;
return Perform_calculation;
public static Calculate performProduct(){
Calculate Perform_calculation = (int a,int b)->a*b;
return Perform_calculation;
public static Calculate performDivision(){
Calculate Perform_calculation = (int a,int b)->{
float c = (float)a;
float d = (float)b;
return (c/d);
};
return Perform_calculation;
public interface Calculate {
float performCalculation(int a,int b);
GD HOSPITAL
Payment Inheritance
[Link]
public class Bill {
public String processPayment(Payment obj) {
String message = "Payment not done and your due amount is "+[Link]();
if(obj instanceof Cheque ) {
Cheque cheque = (Cheque) obj;
if([Link]())
message = "Payment done succesfully via cheque";
else if(obj instanceof Cash ) {
Cash cash = (Cash) obj;
if([Link]())
message = "Payment done succesfully via cash";
else if(obj instanceof Credit ) {
Credit card = (Credit) obj;
if([Link]())
message = "Payment done succesfully via creditcard. Remainig amount in your
"+[Link]()+" card is "+[Link]();
return message;
[Link]
public class Cash extends Payment{
private int cashAmount;
public int getCashAmount() {
return cashAmount;
public void setCashAmount(int cashAmount) {
[Link] = cashAmount;
@Override
public boolean payAmount() {
return getCashAmount() >= getDueAmount();
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class Cheque extends Payment {
private String chequeNo;
private int chequeAmount;
private Date dateOfIssue;
public String getChequeNo() {
return chequeNo;
}
public void setChequeNo(String chequeNo) {
[Link] = chequeNo;
}
public int getChequeAmount() {
return chequeAmount;
}
public void setChequeAmount(int chequeAmount) {
[Link] = chequeAmount;
}
public Date getDateOfIssue() {
return dateOfIssue;
}
public void setDateOfIssue(Date dateOfIssue) {
[Link] = dateOfIssue;
@Override
public boolean payAmount() {
int months = findDifference(getDateOfIssue());
return (getChequeAmount() >= getDueAmount() & months <= 6);
}
private int findDifference(Date date) {
Calendar myDate = new GregorianCalendar();
[Link](date);
return (2020 - [Link]([Link])) * 12 + ([Link]([Link]));
}
public void generateDate(String date) {
try {
Date issueDate = new SimpleDateFormat("dd-MM-yyyy").parse(date);
setDateOfIssue(issueDate);
}
catch (ParseException e) {
[Link]();
}
}
}
[Link]
public class Credit extends Payment {
private int creditCardNo;
private String cardType;
private int creditCardAmount;
public int getCreditCardNo(){
return creditCardNo;
public void setCreditCardNo(int creditCardNo) {
[Link] = creditCardNo;
public String getCardType() {
return cardType;
public void setCardType(String cardType) {
[Link] = cardType;
public int getCreditCardAmount() {
return creditCardAmount;
public void setCreditCardAmount(int creditCardAmount) {
[Link] = creditCardAmount;
@Override
public boolean payAmount() {
int tax = 0;
boolean isDeducted = false;
switch(cardType) {
case "silver":
setCreditCardAmount(10000);
tax = (int) (0.02*getDueAmount())+getDueAmount();
if(tax <= getCreditCardAmount()) {
setCreditCardAmount(getCreditCardAmount()-tax);
isDeducted = true;
break;
case "gold":
setCreditCardAmount(50000);
tax = (int) (0.05*getDueAmount())+getDueAmount();
if(tax <= getCreditCardAmount()) {
setCreditCardAmount(getCreditCardAmount()-tax);
isDeducted = true;
}
break;
case "platinum":
setCreditCardAmount(100000);
tax = (int) (0.1*getDueAmount())+getDueAmount();
if(tax <= getCreditCardAmount()) {
setCreditCardAmount(getCreditCardAmount()-tax);
isDeducted = true;
break;
return isDeducted;
[Link]
import [Link];
public class Main {
public static void main(String[] args) {
Bill bill = new Bill();
Scanner sc = new Scanner([Link]);
[Link]("Enter the due amount:");
int dueAmount = [Link]();
[Link]("Enter the mode of payment(cheque/cash/credit):");
String mode = [Link]();
switch (mode) {
case "cash":
[Link]("Enter the cash amount:");
int cashAmount = [Link]();
Cash cash = new Cash();
[Link](cashAmount);
[Link](dueAmount);
[Link]([Link](cash));
break;
case "cheque":
[Link]("Enter the cheque number:");
String number = [Link]();
[Link]("Enter the cheque amount:");
int chequeAmount = [Link]();
[Link]("Enter the date of issue:");
String date = [Link]();
Cheque cheque = new Cheque();
[Link](chequeAmount);
[Link](number);
[Link](date);
[Link](dueAmount);
[Link]([Link](cheque));
break;
case "credit":
[Link]("Enter the credit card number.");
int creditNumber = [Link]();
[Link]("Enter the card type(silver,gold,platinum)");
String cardType = [Link]();
Credit credit = new Credit();
[Link](cardType);
[Link](creditNumber);
[Link](dueAmount);
[Link]([Link](credit));
default:
break;
[Link]();
[Link]
public class Payment {
private int dueAmount;
public int getDueAmount() {
return dueAmount;
}
public void setDueAmount(int dueAmount) {
[Link] = dueAmount;
public boolean payAmount() {
return false;
HUNGER EATS
package [Link];
import [Link].*;
import [Link];
public class Order{
private double discountPercentage;
private List<FoodProduct> foodList=new ArrayList<FoodProduct>();
public double getDiscountPercentage() {
return discountPercentage;
}
public void setDiscountPercentage(double discountPercentage) {
[Link] = discountPercentage;
}
public List<FoodProduct> getFoodList() {
return foodList;
}
public void setFoodList(List<FoodProduct> foodList) {
[Link] = foodList;
}
public void findDiscount(String bankName)
{
if([Link]("HDFC")) {
discountPercentage=15.0;
}
else if([Link]("ICICI")) {
discountPercentage=25.0;
}
else if([Link]("CUB")) {
discountPercentage=30.0;
}
else if([Link]("SBI")) {
discountPercentage=50.0;
}
else if([Link]("OTHERS")) {
discountPercentage=0.0;
}
public void addToCart(FoodProduct foodProductObject)
{
List<FoodProduct> f=getFoodList();
[Link](foodProductObject);
setFoodList(f);
public double calculateTotalBill()
{
double bill = 0;
List<FoodProduct> f=getFoodList();
for(int i=0;i<[Link]();i++)
{
// [Link]([Link](i).getCostPerUnit());
// [Link]([Link](i).getQuantity());
bill+=[Link](i).getQuantity()*[Link](i).getCostPerUnit()*1.0;
}
// [Link](bill);
// [Link](dis);
bill=bill-((bill*discountPercentage)/100);
return bill;
}
}
package [Link];
import [Link];
import [Link];
import [Link];
public class UserInterface{
public static void main(String[] args) {
Scanner sc=new Scanner([Link]);
int itemno;
String bank;
[Link]("Enter the number of items");
itemno=[Link]();
[Link]("Enter the item details");
Order o=new Order();
for(int i=0;i<itemno;i++)
{
FoodProduct fd=new FoodProduct();
[Link]("Enter the item id");
[Link]([Link]());
[Link]("Enter the item name");
[Link]([Link]());
[Link]("Enter the cost per unit");
[Link]([Link]());
[Link]("Enter the quantity");
[Link]([Link]());
[Link](fd);
[Link]("Enter the bank name to avail offer");
bank=[Link]();
[Link](bank);
[Link]("Calculated Bill Amount:"+[Link]());
}
}
package [Link];
public class FoodProduct {
private int foodId;
private String foodName;
private double costPerUnit;
private int quantity;
public int getFoodId() {
return foodId;
}
public void setFoodId(int foodId) {
[Link] = foodId;
}
public String getFoodName() {
return foodName;
}
public void setFoodName(String foodName) {
[Link] = foodName;
}
public double getCostPerUnit() {
return costPerUnit;
}
public void setCostPerUnit(double costPerUnit) {
[Link] = costPerUnit;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
[Link] = quantity;
}
Singapore
import [Link].*;
public class tourism {
static String name;
static String place;
static int days;
static int tickets;
static double price = 0.00;
static double total = 0.00;
public static void main(String[] args){
Scanner in = new Scanner([Link]);
[Link]("Enter the passenger name");
name = [Link]();
[Link]("Enter the place name");
place=[Link]();
if([Link]("beach")
||[Link]("pilgrimage")||[Link]("heritage")||[Link]
reCase("Hills")||[Link]("palls")||[Link]("adventure")){
[Link]("Enter the number of days");
days = [Link]();
if(days>0){
[Link]("Enter the number of Tickets");
tickets = [Link]();
if(tickets>0){
if([Link]("beach")){
price = tickets*270;
if(price>1000){
total = 85*price/100;
[Link]("Price:%.2f",total);
}
else {
[Link]("Price:%.2f",price);
}
}
else if([Link]("prilgrimage")){
price = tickets*350;
if(price>1000){
total = 85*price/100;
[Link]("Price:%.2f",total);
}
else {
[Link]("Price:%.2f",price);
}
}
else if([Link]("heritage")){
price = tickets*430;
if(price>1000){
total = 85*price/100;
[Link]("Price:%.2f",total);
}
else {
[Link]("Price:%.2f",price);
}
}
else if([Link]("hills")){
price = tickets*780;
if(price>1000){
total = 85*price/100;
[Link]("Price:%.2f",total);
}
else {
[Link]("Price:%.2f",price);
}
}
else if([Link]("palls")){
price = tickets*1200;
if(price>1000){
total = 85*price/100;
[Link]("Price:%.2f",total);
}
else {
[Link]("Price:%.2f",price);
}
}
else {
price = tickets*4500;
if(price>1000){
total = 85*price/100;
[Link]("Price:%.2f",total);
}
else {
[Link]("Price:%.2f",price);
}
}
}
else{
[Link](tickets+" is an Invalid no. of tickets");
}
}
else{
[Link](days+" is an Invalid no. of days");
}
}
else {
[Link](place+" is an Invalid place");
}
}
}
Prime no ending
import [Link].*;
public class Main
{
public static void main (String[] args) {
int flag=0, k=0, z=0;
Scanner sc =new Scanner([Link] );
[Link]("Enter the first number");
int f=[Link]();
[Link]("Enter the last number");
int l=[Link]();
for(int i=f; i<=l; i++)
{
for(int j=2; j<i; j++)// this loop increments flag if i is divisible by j
{
if(i%j==0)
{
flag++;
}
}
if(i==l && (flag!=0 || i%10!=1))//when last number is not a prime
{
while(z==0)
{
for(int a=2; a<i; a++)
{
if(i%a==0)
{
flag++;
}
}
if(i%10==1 && flag==0)
{
[Link](","+i);
z++;
}
flag=0;
i++;
}
}
if(i%10==1 && flag==0)//to check for last digit 1 and prime
{
if(k==0)
{
[Link](i);
k++;
}
else
{
[Link](","+i);
}
}
flag=0;
}
}
}
Query Set
public class Query {
private class DataSet{
private String theatreId;
private String theatreName;
private String location;
private int noOfScreen;
private double ticketCost;
public String getTheatreId() {
return theatreId;
}
public void setTheatreId(String theatreId) {
[Link] = theatreId;
}
public String getTheatreName() {
return theatreName;
}
public void setTheatreName(String theatreName) {
[Link] = theatreName;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
[Link] = location;
}
public int getNoOfScreen() {
return noOfScreen;
}
public void setNoOfScreen(int noOfScreen) {
[Link] = noOfScreen;
}
public double getTicketCost() {
return ticketCost;
}
public void setTicketCost(double ticketCost) {
[Link] = ticketCost;
}
@Override
public String toString() {
return "Theatre id: " + theatreId + "\nTheatre name: " + theatreName + "\nLocation: " + location
+ "\nNo of Screen: " + noOfScreen + "\nTicket Cost: " + ticketCost+"\n";
}
}
private String queryId;
private String queryCategory;
private DataSet primaryDataset;
private DataSet secondaryDataSet;
public String getQueryId() {
return queryId;
}
public void setQueryId(String queryId) {
[Link] = queryId;
}
public String getQueryCategory() {
return queryCategory;
}
public void setQueryCategory(String queryCategory) {
[Link] = queryCategory;
}
public DataSet getPrimaryDataset() {
return primaryDataset;
}
public void setPrimaryDataset(DataSet primaryDataset) {
[Link] = primaryDataset;
}
public DataSet getSecondaryDataSet() {
return secondaryDataSet;
}
public void setSecondaryDataSet(DataSet secondaryDataSet) {
[Link] = secondaryDataSet;
}
@Override
public String toString() {
return "Primary data set\n" + primaryDataset
+ "Secondary data set\n" + secondaryDataSet +"Query id: "+ queryId + "\nQuery category=" +
queryCategory;
}
import [Link];
public class TestApplication {
public static void main(String[] args) {
Query query = new Query();
Scanner sc = new Scanner([Link]);
[Link] primary = [Link] DataSet();
[Link] secondary = [Link] DataSet();
[Link]("Enter the Details of primary data set");
[Link]("Enter the theatre id");
String theatreid = [Link]();
[Link](theatreid);
[Link]();
[Link]("Enter the theatre name");
String theatrename = [Link]();
[Link](theatrename);
[Link]();
[Link]("Enter the location");
String location = [Link]();
[Link](location);
[Link]();
[Link]("Entrer the no of screens");
int screens = [Link]();
[Link](screens);
[Link]("Ente the ticket cost");
double cost = [Link]();
[Link](cost);
[Link]("ENter the details of secondary data set");
[Link]("Enter the theatre id");
theatreid = [Link]();
[Link](theatreid);
[Link]();
[Link]("Enter the theatre name");
theatrename = [Link]();
[Link](theatrename);
[Link]();
[Link]("Enter the location");
location = [Link]();
[Link](location);
[Link]();
[Link]("Entrer the no of screens");
screens = [Link]();
[Link](screens);
[Link]("Ente the ticket cost");
cost = [Link]();
[Link](cost);
[Link]("Enter the query id");
String queryid = [Link]();
[Link](queryid);
[Link]();
[Link]("Enter the query category");
String querycategory = [Link]();
[Link](querycategory);
[Link]();
[Link](primary);
[Link](secondary);
[Link](query);
}
}
Extract book
import [Link];
class ExtractBook {
public static int extractDepartmentCode(String input) {
return [Link]([Link](0, 3));
}
public static String extractDepartmentName(int code) {
switch (code) {
case 101:
return "Accounting";
case 102:
return "Economics";
case 103:
return "Engineering";
}
throw new Error(code + " is invalid department code");
}
public static int extractDate(String input) {
String yearStr = [Link](3, 7);
try {
int year = [Link](yearStr);
if (year > 2020 || year < 1900) {
throw new NumberFormatException();
}
return year;
} catch (NumberFormatException e) {
throw new Error(yearStr + " is invalid year");
}
public static int extractNumberOfPages(String input) {
String pagesStr = [Link](7, 12);
try {
int pages = [Link](pagesStr);
if (pages < 10) {
throw new NumberFormatException();
}
return pages;
} catch (NumberFormatException e) {
throw new Error(pagesStr + " are invalid pages");
}
}
public static String extractBookId(String input) {
String id = [Link](12, 18);
if ())
throw new NumberFormatException();
try {
[Link]([Link](1));
} catch (NumberFormatException e) {
throw new Error(id + " is invalid book id");
}
return id;
}
public static void parseAndPrint(String str) {
if ([Link]() != 18) {
[Link](str + " is an invalid input");
return;
}
try {
int dCode = extractDepartmentCode(str);
String dString = extractDepartmentName(dCode);
int year = extractDate(str);
int pages = extractNumberOfPages(str);
String bookId = extractBookId(str);
[Link]("Department Code: " + dCode);
[Link]("Department Name: " + dString);
[Link]("Year of Publication: " + year);
[Link]("Number of Pages: " + pages);
[Link]("Book Id: " + bookId);
} catch (Error e) {
[Link]([Link]());
}
}
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
String input = [Link]();
parseAndPrint(input);
[Link]();
}
}
Fixed deposit
import [Link].*;
class FDScheme {
private int schemeNo;
private double depositAmt;
private int period;
private float rate;
public FDScheme(int schemeNo, double depositAmt, int period) {
super();
[Link] = schemeNo;
[Link] = depositAmt;
[Link] = period;
calculateInterestRate();
}
public int getSchemeNo() {
return schemeNo;
}
public void setSchemeNo(int schemeNo) {
[Link] = schemeNo;
}
public double getDepositAmt() {
return depositAmt;
}
public void setDepositAmt(double depositAmt) {
[Link] = depositAmt;
}
public int getPeriod() {
return period;
}
public void setPeriod(int period) {
[Link] = period;
}
public float getRate() {
return rate;
}
public void setRate(float rate) {
[Link] = rate;
}
public void calculateInterestRate()
{
if(period>=1 && period<=90)
{
[Link]=(float) 5.5;
}
else if(period>=91 && period<=180)
{
[Link]=(float) 6.25;
}
else if(period>=181 && period<=365)
{
[Link]=(float) 7.5;
}
[Link]("Interest rate for "+period+" days is "+[Link]);
}
}
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner([Link]);
[Link]("Enter Scheme no");
int no=[Link]();
[Link]();
[Link]("Enter Deposit amount");
double amt=[Link]();
[Link]("enter period of deposit");
int prd=[Link]();
FDScheme obj=new FDScheme(no,amt,prd);
}
}
Annual Salary
import [Link].*;
public class Main
{
public static void main(String[] args)throws IOException
{
// Scanner sc=new Scanner([Link]);
//Fill the code
BufferedReader br=new BufferedReader(new InputStreamReader([Link]));
[Link]("Enter the Employee Name");
String name=[Link]();
[Link]("Enter percentage of salary");
double percent=[Link]([Link]());
if(percent>0&&percent<20)
{
[Link]("Enter the Year of Experience");
int time=[Link]([Link]());
if(time>0&&time<15)
{
double permonth=12000+(2000*(time));
double dayshift=permonth*6;
double nightshift=(((permonth*percent)/100)+permonth)*6;
double annualIncome=dayshift+nightshift;
String str="The annual salary of "+name+" is";
[Link](str+" "+annualIncome);
}
else{
[Link]((int)time+" is an invalid year of experience");}
}
else
[Link]((int)percent+" is an invalid percentage");
}
}
Amity Passenger
import [Link].*;
public class PassengerAmenity {
public static void main(String[] args) {
Scanner sc=new Scanner([Link]);
[Link]("Enter the number of passengers");
int no=[Link]();
[Link]();
int count=0;
if(no>0)
{
String name[]=new String[no];
String seat[]=new String[no];
String arr[]=new String[no];
for(int i=0;i<no;i++)
{
[Link]("Enter the name of the passenger "+(i+1));
String str=[Link]();
name[i]=[Link]();
[Link]("Enter the seat details of the passenger "+(i+1));
seat[i]=[Link]();
if(seat[i].charAt(0)>='A' && seat[i].charAt(0)<='S')
{
int r=[Link](seat[i].substring(1,seat[i].length()));
if(r>=10 && r<=99)
{
count++;
}
else
{
[Link](r+" is invalid seat number");
break;
}
}
else
{
[Link](seat[i].charAt(0)+" is invalid coach");
break;
}
arr[i]=name[i]+" "+seat[i];
}
if(count==[Link])
{
[Link](seat);
for(int i=[Link]-1;i>=0;i--)
{
for(int j=0;j<[Link];j++)
{
if(arr[j].contains(seat[i]))
{
[Link](arr[j]);
}
}
}
}
}
else
{
[Link](no+" is invalid input");
}
}
Change the Case
import [Link].*;
public class ChangeTheCase {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
String a = [Link]();
if([Link]() < 3) {
[Link]("String length of " + a + " is too short");
return;
}
else if([Link]() > 10) {
[Link]("String length of " + a + " is too long");
return;
}
char[] arr = [Link]();
char[] arr1 = new char[[Link]];
int j = 0;
for(int i = 0; i < [Link](); i++) {
if((arr[i]<65 || ((arr[i]>90) && (arr[i]<97)) || arr[i]>122)) {
arr1[j++] = arr[i];
}
}
if(j!=0) {
[Link]("String should not contain ");
for(int i = 0; i<=j; i++) {
[Link](arr1[i]);
}
return;
}
char b = [Link]().charAt(0);
int present = 0;
for(int i = 0; i<[Link](); i++) {
if(arr[i] == [Link](b)) {
arr[i] = [Link](b);
present = 1;
}
else if(arr[i] == [Link](b)) {
arr[i] = [Link](b);
present = 1;
}
}
if(present == 0) {
[Link]("Character " + b + " is not found");
}
else {
for(int i = 0; i <[Link](); i++) {
[Link](arr[i]);
}
}
}
Club Member
import [Link];
public class ClubMember {
private int memberId;
private String memberName;
private String memberType;
private double membershipFees;
public ClubMember(int memberId, String memberName, String memberType) {
super();
[Link] = memberId;
[Link] = memberName;
[Link] = memberType;
calculateMembershipFees();
}
public int getMemberId() {
return memberId;
}
public void setMemberId(int memberId) {
[Link] = memberId;
}
public String getMemberName() {
return memberName;
}
public void setMemberName(String memberName) {
[Link] = memberName;
}
public String getMemberType() {
return memberType;
}
public void setMemberType(String memberType) {
[Link] = memberType;
}
public double getMembershipFees() {
return membershipFees;
}
public void setMembershipFees(double membershipFees) {
[Link] = membershipFees;
}
public void calculateMembershipFees() {
if(!(memberType == "Gold"))
{
[Link]=(double) 50000.0;
}
else if(!(memberType=="Premium"))
{
[Link]=(double) 75000.0;
}
[Link]("Member Id is "+[Link]);
[Link]("Member Name is "+[Link]);
[Link]("Member Type is "+[Link]);
[Link]("Membership Fees is "+[Link]);
}
}
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner([Link]);
[Link]("Enter Member Id");
int id=[Link]();
[Link]();
[Link]("Enter Name");
String name=[Link]();
[Link]("Enter Member Type");
String type=[Link]();
ClubMember club=new ClubMember(id, name, type);
//[Link]();
}
}