JAVA PROGRAMMING
Lab Assignment - 5
ADVAITHA B
19BBS0049
Class 8
Q1
package class8_q1;
import java.util.Scanner;
/**
* @param args the command line arguments
*/
import java.util.Scanner;
import java.util.Arrays;
class Thread1 implements Runnable{
public void run(){
Scanner in = new Scanner (System.in);
String[] item={"Pen","Pencil","Eraser","Sketch","Paper"};
System.out.println(Arrays.toString(item));
System.out.println();
String[] item_new=new String[4];
System.out.println("Enter the item to be removed: ");
String s=in.nextLine();
int j=0;
for(int i=0;i<5;i++){
if(!item[i].equalsIgnoreCase(s)){
item_new[j]=item[i];
j++;
System.out.println("\nUpdated Item array:-");
System.out.println(Arrays.toString(item_new));
System.out.println();
}
class Thread2 implements Runnable{
public void run(){
Scanner in = new Scanner (System.in);
String[] item={"Pen","Pencil","Eraser","Sketch","Paper"};
String[] item_new=new String[item.length-1];
int[] price={15,5,6,30,10};
int[] price_new=new int[price.length-1];
// System.out.println("\nEnter the Stationary whose amount is to be removed: ");
// String s=in.nextLine();
System.out.println("ENTER AMOUNT-Pen:15 Pencil:5 Eraser:6 Sketch:30 Paper:10");
int amount=in.nextInt();
System.out.println();
for(int i=0;i<price.length;i++){
if(amount==price[i]){
for(int j=1;j<price.length-1;j++){
price[j]=price[j+1];
System.out.println("\nUpdated Price array:-");
for(int i=0;i<price.length-1;i++){
System.out.println(price[i]+" ");
System.out.println();
class Thread3 implements Runnable{
public void run(){
Scanner in = new Scanner (System.in);
String[] item={"Pen","Pencil","Eraser","Sketch","Paper"};
int[] price={15,5,6,30,10};
System.out.println("\nEnter the Stationary item whose price is to be known: ");
String s=in.nextLine();
if(s.equals("Pen")){
System.out.println("The price of Pen is:- 15 Rs.");
if(s.equals("Pencil")){
System.out.println("The price of Pencil is:- 5 Rs.");
if(s.equals("Eraser")){
System.out.println("The price of Eraser is:- 6 Rs.");
if(s.equals("Sketch")){
System.out.println("The price of Sketch is:- 30 Rs.");
if(s.equals("Paper")){
System.out.println("The price of Paper is:- 10 Rs.");
public class Class8_q1 {
public static void main(String[] args) throws InterruptedException {
System.out.println("Advaitha B - 19BBS0049");
Thread1 th1 = new Thread1();
Thread t1 = new Thread(th1);
Thread2 th2 = new Thread2();
Thread t2 = new Thread(th2);
Thread3 th3 = new Thread3();
Thread t3 = new Thread(th3);
t1.start();
t1.join();
t2.start();
t2.join();
t3.start();
t3.join();
}
Q2
package class8_q2;
class BusRegistration{
String BusName;
int NumberOfSeats;
BusRegistration(String bn,int seat){
BusName=bn;
NumberOfSeats=seat;
}
//register seat
synchronized void RegisterSeat(){
if (NumberOfSeats==0) {
System.out.println("[-]"+Thread.currentThread().getName()+" says seat are
0!");
try {wait();}
catch(Exception ue) {System.out.println("[!]Exception occured at register
seat :"+ ue);}
NumberOfSeats=NumberOfSeats-1; //deduct 1 seat
System.out.println("[+] Seat registered by "+Thread.currentThread().getName());
//allocate seat
synchronized void AllocateSeat(int seats) {
NumberOfSeats=NumberOfSeats+seats;
System.out.println("[+] "+Thread.currentThread().getName()+" added "+seats+"
seats, total "+NumberOfSeats+"seats left!");
notifyAll();
//display seats remaining
void display() { //enquiring the value no need to be synchronized
System.out.println("[*] Total number of seats remaning are: "+NumberOfSeats+"
says "+Thread.currentThread().getName());
public class Class8_q2 {
public static void main(String[] args) {
System.out.println("Advaitha B (19BBS0049) ");
BusRegistration c=new BusRegistration("Java Programming",0); //initialisze
constructor
Thread t1=new Thread() {
public void run() {c.RegisterSeat();}
};
Thread t2=new Thread() {
public void run() {c.RegisterSeat();}
};
Thread t3=new Thread() {
public void run() {c.AllocateSeat(60);}
};
Thread t4=new Thread() {
public void run() {c.display();}
};
t1.start();
t2.start();
t3.start();
t4.start();
}
Q3
package class8_q3;
import java.util.Scanner;
class cake{
int balance = 0;
synchronized void produce(int pro){
Scanner sc = new Scanner(System.in);
System.out.println("Producer.................");
if(balance+pro>10){
try{
wait();
catch(Exception e){}
balance = balance + pro;
System.out.println("Balance: "+ balance);
notify();
}
synchronized void consume(int con){
System.out.println("Consumer.................");
if(balance-con<0){
try{
wait();
catch(Exception e){}
balance = balance-con;
System.out.println("Balance: "+ balance);
notify();
public class Class8_Q3 {
public static void main(String[] args) {
System.out.println("Advaitha B (19BBS0049) ");
Scanner sc = new Scanner(System.in);
cake c = new cake();
new Thread(){
public void run(){
c.produce(5);
}.start();
new Thread(){
public void run(){
c.produce(3);
}.start();
new Thread(){
public void run(){
c.consume(9);
}.start();
Class 9
Q1
package classfiles_q1;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Classfiles_Q1 {
public static void main(String[] args){
System.out.println("Advaitha B (19BBS0049) ");
File f = new File("abc.txt");
try{
if(f.createNewFile())
System.out.println("File created............");
else
System.out.println("File already exists............");
}catch(IOException e){
e.printStackTrace();
String rev = "";
try{
FileInputStream fin = new FileInputStream("abc.txt");
int i=0;
while((i=fin.read())!=-1){
rev = (char)i + rev;
fin.close();
}catch(IOException e){
e.printStackTrace();
byte b[] = rev.getBytes();
try{
FileOutputStream fout = new FileOutputStream("abc.txt");
fout.write(b);
fout.close();
}catch(IOException e){
e.printStackTrace();
System.out.println("Sucess........");
}
}
Q2
package class9_q2;
import java.util.Scanner;
import java.io.*;
public class Class9_Q2 {
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
System.out.println("Advaitha B (19BBS0049) ");
File f = new File("xyz.txt");
try{
if(f.createNewFile())
System.out.println("File created............");
else
System.out.println("File already exists............");
}catch(IOException e){
e.printStackTrace();
BufferedWriter bw=new BufferedWriter(new FileWriter(f));
//to write all alphabet
for(int i=65;i<91;i++) {
bw.write(i);
//read and write from console
bw.newLine(); // change line
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter letters");
String letter=reader.readLine();
bw.write(letter);
bw.flush();
bw.close();
}
Q3
package class9_q3;
/**
* @author ADVAITHA B
*/
import java.io.*;
import java.util.Scanner;
public class Class9_Q3 {
public static void main(String[] args) throws InterruptedException {
System.out.println("Advaitha B - 19BBS0049");
Scanner sc = new Scanner(System.in);
try {
File f1 = new File("file1.txt");
File f2 = new File("file2.txt");
f1.createNewFile();
f2.createNewFile();
DataOutputStream dos1 = new DataOutputStream(new FileOutputStream(f1));
DataOutputStream dos2 = new DataOutputStream(new FileOutputStream(f2));
try {
dos1.writeBytes("Princess Diana of an all-female Amazonian race rescues US pilot Steve.
Upon learning of a war, she ventures into the world of men to stop Ares, the god of war, from
destroying mankind");
dos2.writeBytes("Batman ventures into Gotham City's underworld when a sadistic killer
leaves behind a trail of cryptic clues.");
} catch (Exception e) {}
Scanner sc1 = new Scanner(f1);
Scanner sc2 = new Scanner(f2);
Thread t1 = new Thread(()->{
try {
int count1 = 0, count2 = 0, count3 = 0;
System.out.print(".."+Thread.currentThread().getName()+".. Starting now... Reading from
file ...."+f1.getName()+"....\n");
String s;
while(sc1.hasNextLine()){
s = sc1.nextLine();
String[] str = s.split(" ");
for(int i=0; i<str.length; i++){
if(str[i].equals("a") || str[i].equals("A")){
count1++;
else if(str[i].equals("And") || str[i].equals("and")){
count2++;
else if(str[i].equals("The") || str[i].equals("the")){
count3++;
}
System.out.println("Number of times \"a\" occurs is "+count1+"\nNumber of
times \"and\" occurs is "+count2+"\nNumber of times \"the\" occurs is "+count3);
} catch (Exception e) {}
});
Thread t2 = new Thread(()->{
try {
int count4 = 0;
System.out.print(".."+Thread.currentThread().getName()+".. Starting now... Reading from
file ...."+f2.getName()+"....\n");
String s1;
while(sc2.hasNextLine()){
s1 = sc2.nextLine();
String[] str1 = s1.split(" ");
for(int i=0; i<str1.length; i++){
if(str1[i].charAt(0) == 'H'){
count4++;
System.out.println("Number of times a word starts with \"H\" is "+count4);
} catch (Exception e) {}
});
Thread t3 = new Thread(()->{
try {
System.out.print(".."+Thread.currentThread().getName()+"Starting now... \nThanks for
using our software....\n");
} catch (Exception e) {}
});
t1.start();
t2.start();
t1.join();
t2.join();
t3.start();
t3.join();
dos1.close();
dos2.close();
} catch (Exception e) {}
Q4
package class9_q4;
/**
*
* @author ADVAITHA B
*/
import java.util.Scanner;
class threadprime {
public static void main(String args[]){
int i,count;
System.out.println("Advaitha 19BBS0049");
Scanner S=new Scanner(System.in);
System.out.println("Enter the number:");
int n=S.nextInt();
System.out.println("Prime numbers between 1 to "+n+" are");
for(int j=2;j<=n;j++){
count=0;
for(i=1;i<=j;i++){
if(j%i==0) {
count++;
if(count==2)
System.out.println(j+"");
public class Class9_Q4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int i,count;
System.out.println("Enter n value:");
Scanner S=new Scanner(System.in);
int n=S.nextInt();
System.out.println("Prime numbers between 1 to "+n+":");
for(int j=2;j<=n;j++){
count=0;
for(i=101;i<=j;i++){
if(j%i==0) {
count++;
if(count==2)
System.out.println(j+"");
Class 10
Q1
package class10_q1;
import java.util.*;
/**
*
* @author ADVAITHA B
*/
interface StringSort{
public void sort();
public class Class10_Q1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Advaitha B (19BBS0049) ");
//arrayList
ArrayList<String> list =new ArrayList<String>();
list.add("It is a long established fact that a reader will be distracted by the readable
content of a page when looking at its layout. ");
list.add("The point of using Lorem Ipsum is that it has a more-or-less normal
distribution of letters, as opposed to using 'Content here, content here', making it look like readable
English. ");
list.add("Many desktop publishing packages and web page editors now use Lorem
Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in
their infancy.");
list.add("Various versions have evolved over the years, sometimes by accident,
sometimes on purpose (injected humour and the like).");
int size=list.size(); // List size
StringSort length =()->{
//lambda expression for length sort
String t;
for(int i=0;i<size;i++) {
for(int j=i;j<size;j++) {
if((list.get(i)).length()>(list.get(j)).length()) {
t=list.get(i);
list.set(i,list.get(j));
list.set(j,t);
//Traversing list through iterator
Iterator itr=list.iterator();
while(itr.hasNext()) {
System.out.println(itr.next());
};
StringSort lengthreverse =()->{
//lambda expression for length sort
String t;
for(int i=0;i<size;i++) {
for(int j=i;j<size;j++) {
if((list.get(i)).length()<(list.get(j)).length()) {
t=list.get(i);
list.set(i,list.get(j));
list.set(j,t);
//Traversing list through iterator
Iterator itr=list.iterator();
while(itr.hasNext()) {
System.out.println(itr.next());
}
};
StringSort alphabatical =()->{
//lambda expression for length sort
String t;
for(int i=0;i<size;i++) {
char a=(list.get(i)).charAt(0); //only first character
for(int j=i;j<size;j++) {
char b=(list.get(j)).charAt(0); //only first character
int compare = Character.compare(a,b);
if(compare>0) {
t=list.get(i);
list.set(i,list.get(j));
list.set(j,t);
else {
continue;
//Traversing list through iterator
Iterator itr=list.iterator();
while(itr.hasNext()) {
System.out.println(itr.next());
};
StringSort withe =()->{
//lambda expression for length sort
String t;
for(int i=0;i<size;i++) {
for(int j=i;j<size;j++) {
int a=(list.get(i)).indexOf("e");
int b=(list.get(j)).indexOf("e");
if(a>b) {
t=list.get(i);
list.set(i,list.get(j));
list.set(j,t);
else {
continue;
//Traversing list through iterator
Iterator itr=list.iterator();
while(itr.hasNext()) {
System.out.println(itr.next());
};
// calling lambda functions
System.out.println("[+] Sorting as");
System.out.println("[~] Length i.e. shortest to longest");
length.sort();
System.out.println("\n[~] Reversed Length i.e. longest to shortest");
lengthreverse.sort();
System.out.println("\n[~] alphabatically i.e. first character");
alphabatical.sort();
System.out.println("\n[~] String with 'e' first");
withe.sort();
}
Q2
package class10_q2;
/**
* @author ADVAITHA B
*/
import java.util.*;
interface Capitalize{
public void capitalized();
public class Class10_Q2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Advaitha B (19BBS0049) ");
Scanner sc= new Scanner(System.in);
System.out.println("[*] Enter String to be capitalized: "); // getting string
Capitalize printCapitalized =()->{
String str=sc.nextLine();//input
//lambda expression
char[] charArray = str.toCharArray();
boolean foundSpace = true;
for(int i = 0; i < charArray.length; i++) {
if(Character.isLetter(charArray[i])) {
// check space is present before the letter
if(foundSpace) {
// change the letter into upper case
charArray[i] = Character.toUpperCase(charArray[i]);
foundSpace = false;
else {
// if the new character is not character
foundSpace = true;
str=String.valueOf(charArray);
System.out.println("[+] The processed text is: -> \n\t"+str);
};
//calling method
printCapitalized.capitalized();
}
}
Q3
package class10_q3;
/**
* @author ADVAITHA B
*/
import java.util.*;
class Books{
String bookname,author,price,type;
ArrayList<ArrayList<String>> fiction =new ArrayList<ArrayList<String>>();
ArrayList<ArrayList<String>> comic =new ArrayList<ArrayList<String>>();
ArrayList<ArrayList<String>> cooking =new ArrayList<ArrayList<String>>();
void input() { //one book details add at a time in this method
System.out.println("[?] How many books?");
Scanner s=new Scanner(System.in);
int n=s.nextInt();
for(int i=0;i<n;i++) {
System.out.println("[+] Enter book details: ~ book namme ~ author ~ price ~
type");
Scanner sc=new Scanner(System.in);
bookname=sc.nextLine();
author=sc.nextLine();
price=sc.nextLine();
type=sc.nextLine();
if(type.equals("fiction")) {
fiction.add(new
ArrayList<String>(Arrays.asList(bookname,author,price,type)));
else if(type.equals("comic")) {
comic.add(new
ArrayList<String>(Arrays.asList(bookname,author,price,type)));
else if(type.equals("cooking")) {
cooking.add(new
ArrayList<String>(Arrays.asList(bookname,author,price,type)));
void display() { // all books details displayed
System.out.println("[+] fiction books");
for (List<String> list : fiction) {
for (String item : list) {
System.out.print(" "+ item+ ", ");
}
System.out.print(";\n");
System.out.println("[+] comic books");
for (List<String> list : comic) {
for (String item : list) {
System.out.print(" "+ item+ ", ");
System.out.print(";\n");
System.out.println("[+] cooking books");
for (List<String> list : cooking) {
for (String item : list) {
System.out.print(" "+ item+ ", ");
System.out.print(";\n");
void sortname(ArrayList<ArrayList<String>> books) { // one list of books sorted using book
name
for (int i=0;i<books.size();i++) {
for (int j=i;j<books.size();j++) {
String a =books.get(i).get(0);
String b =books.get(j).get(0);
ArrayList<String> t =new ArrayList<String>();
if(a.compareTo(b)>0) {
t=books.get(i);
books.set(i,books.get(j));
books.set(j,t);
}
}
void sortnamecaller() {
System.out.println("\n[+] sorted books");
sortname(fiction);
sortname(comic);
sortname(cooking);
display();
void maxminprice(ArrayList<ArrayList<String>> books) { //sorting the argument's list price
System.out.println(" ~ price of books");
int pri[]=new int[books.size()];
for (int i=0;i<books.size();i++) {
String p=books.get(i).get(2);
pri[i]=Integer.valueOf(p);
int max=pri[0],min=pri[0];
for (int i=0;i<pri.length;i++) {
if(pri[i]>max) { //for max
max=pri[i];
else if(pri[i]<min) { //for min
min=pri[i];
else {continue;}
System.out.println("~ max price :"+max+"\n~ min price :"+min);
void maxmincaller() {
System.out.println("\n[~] MAX & MIN Prices");
System.out.println("[+] for fiction");
maxminprice(fiction);
System.out.println("[+] for comic");
maxminprice(comic);
System.out.println("[+] for cooking");
maxminprice(cooking);
public class Class10_Q3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Advaitha B (19BBS0049) ");
// TODO Auto-generated method stub
Books b=new Books();
b.input();
b.display();
b.sortnamecaller();
b.maxmincaller();
}
Q4
package class10_q4;
/**
* @author ADVAITHA B
*/
import java.util.*;
public class Class10_Q4 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Advaitha B (19BBS0049) ");
// Hash Map H1
HashMap<String,ArrayList<String>> StudentCourses=new
HashMap<String,ArrayList<String>>();//Creating HashMap
//STUDENT 1
StudentCourses.put("Qwerty",new ArrayList<String>());
StudentCourses.get("Qwerty").add("Python");
StudentCourses.get("Qwerty").add("Java");
StudentCourses.get("Qwerty").add("C");
//STUDENT 2
StudentCourses.put("Asdfg",new ArrayList<String>());
StudentCourses.get("Asdfg").add("C");
StudentCourses.get("Asdfg").add("Java");
//STUDENT 3
StudentCourses.put("Zxcvb",new ArrayList<String>());
StudentCourses.get("Zxcvb").add("Java");
StudentCourses.get("Zxcvb").add("Python");
StudentCourses.get("Zxcvb").add("C++");
// Hash Map H2
HashMap<String,String> CourseFaculty=new HashMap<String,String>();//Creating
HashMap
CourseFaculty.put("C","Aaaa");
CourseFaculty.put("C++","Bbbb");
CourseFaculty.put("Python","Cccc");
CourseFaculty.put("Java","Dddd");
// Matching
for(Map.Entry i : StudentCourses.entrySet()){
System.out.println("[+] For Student "+i.getKey()+" who took "+i.getValue()+"
has faculties");
for(Map.Entry j : CourseFaculty.entrySet()){
if(((i.getValue()).toString()).contains((CharSequence) j.getKey())) {
System.out.println("\t ~ "+j.getValue()+" for the subject
"+j.getKey());
else {
continue;
System.out.println();
}
Class 11
Q1
package class11_q1;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
/**
* @author ADVAITHA B
*/
public class Class11_Q1 extends Application {
public static void main(String[] args) {
// TODO Auto-generated method stub
launch(args);
@Override
public void start(Stage primaryStage) throws Exception {
// TODO Auto-generated method stub
Button red = new Button("RED");
Button green = new Button("GREEN");
Button blue = new Button("BLUE");
Button pink = new Button("PINK");
Button black = new Button("BLACK");
Font font = Font.font("Courier New", FontWeight.BOLD, 20);
red.setFont(font);
green.setFont(font);
blue.setFont(font);
pink.setFont(font);
black.setFont(font);
Label l1=new Label("Advaitha \n19BBS0049");
l1.setFont(Font.font("Courier New", FontWeight.BOLD, 15));
red.setStyle("-fx-background-color: red");
green.setStyle("-fx-background-color: green");
blue.setStyle("-fx-background-color: blue");
pink.setStyle("-fx-background-color: pink");
black.setStyle("-fx-background-color: black");
// print on console
red.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent event){
System.out.println("RED was clicked");
}});
green.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent event){
System.out.println("GREEN was clicked");
}});
blue.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent event){
System.out.println("BLUE was clicked");
}});
pink.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent event){
System.out.println("PINK was clicked");
}});
black.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent event){
System.out.println("BLACK was clicked");
}});
GridPane gp=new GridPane();
gp.setVgap(5);
gp.setHgap(5);
gp.setAlignment(Pos.CENTER);
gp.add(red, 2, 0);
gp.add(green, 2, 1);
gp.add(blue, 2, 2);
gp.add(pink, 2, 3);
gp.add(black, 2, 4);
gp.add(l1, 0, 2);
Scene scene=new Scene(gp,600,600);
primaryStage.setScene(scene);
primaryStage.setTitle("Colors");
primaryStage.show();
}
Q2
package class11_q2;
import javafx.stage.Stage;
import java.time.LocalDate;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
/**
* @author ADVAITHA B
*/
public class Class11_Q2 extends Application {
Scene booked, details;
TextField source,destination,passenger;
ToggleGroup group;
DatePicker date;
String src,des,pass,cls;
LocalDate dat;
public static void main(String[] args) {
// TODO Auto-generated method stub
launch(args);
@Override
public void start(Stage primaryStage) throws Exception {
Label l0=new Label("Advaitha /n 19BBS0049");
Label l1=new Label("Source: ");
l1.setMaxWidth(200);
source=new TextField(); // source
source.setMaxHeight(20);
Label l2=new Label("Destination: ");
l2.setMaxWidth(200);
destination=new TextField(); // destination
destination.setMaxHeight(20);
Label l3=new Label("Date: ");
l3.setMaxWidth(200);
date = new DatePicker(); // date
Label l4=new Label("# Passengers: ");
l4.setMaxWidth(200);
passenger=new TextField(); //number of passenger
passenger.setMaxHeight(20);
Label l5=new Label("Class: ");
l5.setMaxWidth(200);
group = new ToggleGroup();
RadioButton button1 = new RadioButton("Business");
RadioButton button2 = new RadioButton("First");
RadioButton button3 = new RadioButton("Economy");
button1.setToggleGroup(group);
button2.setToggleGroup(group);
button3.setToggleGroup(group);
Button book = new Button("BOOK TICKET!"); // button
// design
Font font = Font.font("Courier New", FontWeight.BOLD, 20);
l0.setFont(font);
l1.setFont(font);
l2.setFont(font);
l3.setFont(font);
l4.setFont(font);
l5.setFont(font);
source.setFont(font);
destination.setFont(font);
passenger.setFont(font);
button1.setFont(font);
button2.setFont(font);
button3.setFont(font);
book.setFont(font);
//scene 1
GridPane gp1=new GridPane();
gp1.setVgap(5);
gp1.setHgap(5);
gp1.setAlignment(Pos.CENTER);
gp1.add(l0, 1, 0);
gp1.add(l1, 0, 1);
gp1.add(source, 2, 1);
gp1.add(l2, 0, 2);
gp1.add(destination, 2, 2);
gp1.add(l3,0,3);
gp1.add(date, 2, 3);
gp1.add(l4, 0, 4);
gp1.add(passenger, 2, 4);
gp1.add(l5, 0, 5);
gp1.add(button1, 2, 5);
gp1.add(button2, 2, 6);
gp1.add(button3, 2, 7);
gp1.add(book, 1, 8);
details=new Scene(gp1,600,600);
// booking
//book.setOnAction(e->primaryStage.setScene(booked));
book.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
// TODO Auto-generated method stub
src=source.getText();
des=destination.getText();
dat=date.getValue();
pass=passenger.getText();
RadioButton rb = (RadioButton)group.getSelectedToggle();
cls=rb.getText();
//scene 2
Label q0=new Label("BOARDING PASS");
Label q1=new Label("Source: "+src);
Label q2=new Label("Destination: "+des);
Label q3=new Label("Date: "+dat);
Label q4=new Label("No. of Passenger: "+pass);
Label q5=new Label("Class: "+cls);
q0.setFont(font);
q1.setFont(font);
q2.setFont(font);
q3.setFont(font);
q4.setFont(font);
q5.setFont(font);
q0.setTextFill(Color.web("blue"));
q1.setStyle("-fx-border-style: dotted; -fx-border-color: black; -fx-border-width: 1");
q2.setStyle("-fx-border-style: dotted; -fx-border-color: black; -fx-border-width: 1");
q3.setStyle("-fx-border-style: dotted; -fx-border-color: black; -fx-border-width: 1");
q4.setStyle("-fx-border-style: dotted; -fx-border-color: black; -fx-border-width: 1");
q5.setStyle("-fx-border-style: dotted; -fx-border-color: black; -fx-border-width: 1");
GridPane gp2=new GridPane();
booked=new Scene(gp2,600,600);
gp2.setVgap(5);
gp2.setHgap(5);
gp2.setAlignment(Pos.CENTER);
gp2.add(q0, 0, 0);
gp2.add(q1, 0, 1);
gp2.add(q2, 0, 2);
gp2.add(q3, 0, 3);
gp2.add(q4, 0, 4);
gp2.add(q5, 0, 5);
primaryStage.setScene(booked);
primaryStage.setTitle("Air Ticket");
primaryStage.show();
});
primaryStage.setScene(details);
primaryStage.setTitle("Air Ticket");
primaryStage.show();
}
Username and pass scsc