Java Programs by JaTIN Sharma
Java Programs by JaTIN Sharma
Sharma
1. Customer Billing
This is a customer billing system as shown below. The
shop accepts payement in three modes- Cash, Debit Card,
Credit Cards. The discount given as per mode of payment
is as followsMode of Payment
Cash
Debit Card
Credit Card
Discount
12%
8%
5%
Unit Price
950
750
2500
As the user selects an item from the Combo Box, its price
is displayed in jTextField2.
If the Member check box is checked then the customer
gets an additional discount of 5% on the net payable
amount.
price= 2500;
}
if(jCheckBox1.isSelected())
{
ad=.05;
}
netd=d+ad;
quantity=Integer.parseInt(jTextField2.getText());
total=price*quantity;
discount=total*netd;
net=total-discount;
totT.setText(""+total);
disT.setText(""+ discount);
netT.setText(""+net);
CODING IN jComboBox1ActionPerformed
if(jComboBox1.getSelectedIndex()==0)
{
jTextField3.setText("Rs. 750");
}
if(jComboBox1.getSelectedIndex()==1)
{
jTextField3.setText("Rs. 950");
}
if(jComboBox1.getSelectedIndex()==2)
{
jTextField3.setText("Rs. 2500");
}
3. Colour Demonstration
A program in which the colour of appropriate control of
button, label and text field changes depending upon users
choice when the user selects a colour from a list.
jLabel4.setBackground(x);
}
if(jCheckBox2.isSelected())
{
jButton1.setBackground(x);
}
if(jCheckBox3.isSelected())
{
jTextField1.setBackground(x);
}
4. Extracting surname
A program that extracts surname from the entered name.
lname=lname+ch;
}
jTextField2.setText(lname);
5. Counting Character
A program to count the occurrence of a particular string in
a string.
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
6. Changing case
A program to change case of a string to upper between
two specified indices of that string
jTextField4.setText(str1+str2+str3);