Sunday, July 17, 2016

Lab exercise Plus 2

1. Design a GUI application in which the user enters a number in the text field and on clicking the button the sum of the digits of the number should be displayed in a label.
Hint : Suppose user enters 123 the output should be 6(1+2+3).

2. Design a GUI application to accept a String from the user in a text field and print using option pane whether it is a palindrome or not. Hint ABBA is a palindrome.

3. Design a GUI application to accept the cost price and selling price form the user in two text fields then calculate the profit or loss incurred.

4. Design a GUI application to accept a character in a text field and print in a label if that character is a vowel: a, e, i, o, or u. The application should be case sensitive.

5. Design a GUI application that repeatedly accepts numbers in a option pane and once the typed number is 0 the maximum and minimum of all numbers typed are displayed.

6. Design a GUI application in java to convert temperature from Celsius to Fahrenheit or vice versa using radio buttons and two text fields

7. Design a GUI application in java to convert kilograms into grams, litres into milliliters, rupees into paisa using combobox and text fields.

8. A book publishing house decided to go in for computerization. The database will be maintained at the back end but you have to design the front end for the company. You have to accept book code, Title, Author and Quantity sold from the user. The Price will be generated depending upon the book code. Net price should be calculated on the basis of the discount given.
Bookseller - 25%
School - 20%
Customer - 5%

9. A networking company decided to computerize its employee salary . Develop an application to store employee's personal data which will be saved in the back end. The front end should accept Name, Father's Name, Mother's Name, Address, Gender, Basic Salary, Medical and Conveyance. Calculate gross and net salary.
Basic Salary              DA                  HRA
>=40000                    35%                37%
>=20000                    25%                32%
>=10000                    25%                30%

10. Create a GUI application to accept a string and display it in reverse order using the substring() method.

11. Create a GUI application to create random whole numbers between 2 float numbers input by the user.

12. Create a GUI application to accept 3 numbers in separate text fields and display  their sum, average, maximum or minimum after rounding the results on the click of appropriate buttons (There are four separate buttons - one for sum, one for average, one for maximum and one for minimum). The result should be displayed in the fourth text field.

13. Create a GUI application to accept the date (as 1), month (as a number like 3 for March) and year (as 2010) in separate text fields and display the date in the format: dd/mm/yy. Take care of the following points while creating the application: Verify the date input before displaying it in the suggested format and display error messages   herever applicable The date is accepted as 1 (for the first of any month) but should be displayed as 01 in the final format. The year is accepted as 2010 but displayed as 10 in the final format.

14. Create an application to accept two strings - First Name and Last name from the  user and display the message Welcome with the complete name of the user.

15. Create an application to accept the radius of a circle, calculate the area and circumference and display the results in a message box after rounding off the area and circumference to an integer number.

16. Modify application to make sure that the user has not input the complete name in the first name text field.

17. Modify the Case Changer application developed in the lesson to display the input text in Title case using the substring(), toLowerCase() and toUpperCase() methods.



Tuesday, September 8, 2015

Sample Objects of different Classes

Classes used to create the above components are as follows:

Component NameClass Name
FrameJFrame
PanelJPanel
ButtonJButton
LabelJLabel
TextFieldJTextField
RadioButtonJRadioButton
ChekBoxJCheckBox
ComboBoxJComboBox



JFrame frame = new JFrame("Welcome");

JPanel panel = new JPanel();

JLabel lblusername = new JLabel("User Name");

JTextField txtusername = new JTextField(30);

JButton btnOk = new JButton("OK");

JRadioButton rbMale = new JRadioButton();

JCheckBox cbHobby = new JCheckBox();

JComboBox cbxCity = new JComboBox();

How to create a object of button class in java


JButton btnOk = new JButton("OK");

here JButton is a class, btnOk is a object of the class JButton.


new is a keyword which allocate memory to btnOk object after taking it from Constructor (JButton()).

here constructor is passing parameter as "OK" which will be displayed on the button.

Basic Java Interface

Let's understand simple Java interface


In the above picture we have create a Frame using JFrame class of Java.
Other components add are like as follows
  1. Frame
  2. Panel
  3. Button
  4. Label
  5. TextField
Classes used to create the above components are as follows:

Component NameClass Name
FrameJFrame
PanelJPanel
ButtonJButton
LabelJLabel
TextFieldJTextField
RadioButtonJRadioButton
ChekBoxJCheckBox
ComboBoxJComboBox

Sunday, August 23, 2015

While Loop Questions

Predict the output of the following codes:

1. int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");

}


2.   int i=110;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}


3.  int i=0;
while(i<10);
{
JOptionPane.showMessageDialog(rootPane,"hello");
i=i+1;
}


4.   int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i++;
}


5.  int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i--;
}


6.  int i=0;
while(i==10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}


7.  while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}


8.  int i=0;
while(i<10)
{
JOptionPane.showMessage Dialog(rootPane. "hello");
}


9. int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i=10;
}


10. int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i=i+1;
i=i-1;
}

11.

while(1)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}

Tuesday, August 18, 2015

if Construct



int age;
age=Integer.parseInt(jTextField1.getText());
if(age<=0)
{
    jLabel2.setText("ERROR");
}
else
{
    if(age>0 && age<=50 )
    {
        jLabel2.setText("Young Age");
    }
    else
    {
        jLabel2.setText("Old Age");
    }
}

Monday, August 17, 2015

List of Programs

1. Write a code to count the number of days.
2. finding  the odd number
3. Create a scoreboard of hockey match
4. Replace a given word with another word
5. Create a login Form
6. Find the largest number out of given 3 numbers
7. Create a discount calculator
8. Write a code to check voter eligibilty age.
9. Write a code to complete your name. accept first, middle, last name.
10. Create a arithmatic operation calculator.
11. Create a color changer form
12. Write a code to count the character in a string.
13. Write a code to reverse the string.
14. Write a code to copy a given string.
15. Write a code to create commission calculator.
16. write a code check the number is palindrome.
17. write a code to reverse the number example. 1234 to 4321.
18. write a code to print the table of any number.
19. Enter any number and display the day of week?
20. Enter any number and display the month?