EX NO 09
GUI PRORAMS
01/10/2024
AIM:-
Develop a GUI application that calculates the tip amount based on the total bill and desired tip
percentage
PROGRAM:-
package Assignment9;
import [Link].*;
import [Link].*;
import [Link].*;
class Group extends JFrame implements ActionListener{
private JLabel la;
private JRadioButton b1,b2,b3,b4;
private JTextField ag;
Group(){
setTitle("AGE GROUP IDENTIFIER");
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
JLabel sy=new JLabel("ENTER YOUR AGE : ");
ag=new JTextField(10);
b1=new JRadioButton("Child");
b2=new JRadioButton("Teenager");
b3=new JRadioButton("Adult");
b4=new JRadioButton("Senior");
JButton pl=new JButton("Submit");
la=new JLabel("");
add(sy);
add(ag);
add(b1);
add(b2);
add(b3);
add(b4);
add(pl);
add(la);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
}
public void actionPerformed(ActionEvent e) {
int age=[Link]([Link]());
if([Link]().equals("Submit")) {
if([Link]() && age<=12)
[Link]("You are classified as a Child");
else if([Link]() && age>=13 && age<=19)
[Link]("You are classified as a Teenager");
else if([Link]() && age>=20 && age<=64)
[Link]("You are classified as a Adult");
else if([Link]() && age>=65)
[Link]("You are classified as a Senior");
else
[Link]("Invalid");
}
}
}
public class Age {
public static void main(String args[])
{
Group gp=new Group();
}
}
SAMPLE OUTPUT:-
AIM:-
Create a GUI application that allows users to select their favorite fruit using radio buttons.
PROGRAM:-
package Assignment9;
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
class Fruit extends JFrame implements ActionListener{
JRadioButton r1,r2,r3,r4;
JLabel la;
Fruit(){
setTitle("FAVOURITE FRUIT");
setLayout(new FlowLayout());
setVisible(true);
r1=new JRadioButton("Apple");
r2=new JRadioButton("Banana");
r3=new JRadioButton("Orange");
r4=new JRadioButton("Grapes");
// [Link](100,50,150,80);
la=new JLabel("");
JButton b1=new JButton("Submit");
add(r1);
add(r2);
add(r3);
add(r4);
add(b1);
add(la);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
}
public void actionPerformed(ActionEvent e) {
if([Link]().equals("Submit")) {
if([Link]())
[Link]("Selected : APPLE");
else if([Link]())
[Link]("Selected : BANANA");
else if([Link]())
[Link]("Selected : ORANGE");
else if([Link]())
[Link]("Selected : GRAPES");
}
}
}
public class Favourite {
public static void main(String[] args) {
Fruit f=new Fruit();
SAMPLE OUTPUT:-
AIM:-
Create a GUI application that allows users to select a subscription plan using radio buttons.
PROGRAM:-
package Assignment9;
import [Link].*;
import [Link].*;
import [Link].*;
class Subscription extends JFrame implements ActionListener{
JLabel la;
JRadioButton b1,b2,b3;
Subscription(){
setTitle("Subscription plan");
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
b1=new JRadioButton("Basic");
b2=new JRadioButton("Standard");
b3=new JRadioButton("Premium");
JButton pl=new JButton("Choose Plan");
la =new JLabel("");
add(b1);
add(b2);
add(b3);
add(pl);
add(la);
[Link](this);
[Link](this);
[Link](this);
[Link](this);
//[Link](this);
}
public void actionPerformed(ActionEvent e) {
if([Link]().equals("Choose Plan")) {
if([Link]())
[Link]("Selected : Basic");
else if([Link]())
[Link]("Selected : Standard");
else if([Link]())
[Link]("Selected : Premium");
}
}
}
public class Plan {
public static void main(String[] args) {
Subscription s=new Subscription();
SAMPLE OUTPUT:-