Chapter 3

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 22

INFORMATICS PRACTICES

PRACTICAL FILE

CLASS : - XII-B
TANISHQ
CHAPTER 3
QUESTION 1
int sum=0,num;
num =
Integer.parseInt(jTextField1.getText());

while ( num > 0 )


{
sum = sum + (num%10) ;
num = num / 10 ;
}

jLabel2.setText(""+sum);
CHAPTER 3
QUESTION 2
String original=jTextField1.getText();
String rev="";
int l=original.length();
for(int i=l-1;i>=0;i--,l--){
rev=rev + original.substring(l-1,l);
}
if(rev.equals(original)){
JOptionPane.showMessageDialog(this,
"YES the string is palindrome");
}
else
JOptionPane.showMessageDialog(this,
"NO the string is not palindrome");
CHAPTER 3
QUESTION 3
double cp , sp , df = 0 ;

cp=Double.parseDouble(jTextField1.getText());

sp=Double.parseDouble(jTextField2.getText());

if(cp>sp)

df = cp - sp ;

jLabel3.setText("You Have a Loss of RS.");

jTextField3.setText(""+df);

else if(sp>cp)

df = sp - cp ;

jTextField3.setText(""+df);

jLabel3.setText("You Have Profit of RS.");

else

{jTextField3.setText("0");

jLabel3.setText("NO PROFIT NO LOSS");}


CHAPTER 3
QUESTION 4
String x=jTextField1.getText();
if (x.equals("a") || x.equals("e") ||
x.equals("i") || x.equals("o") ||
x.equals("u") ||
x.equals("A") || x.equals("E") ||
x.equals("I") || x.equals("O") ||
x.equals("U"))
{ jLabel2.setText("Character is a
vowel");}
else
{ jLabel2.setText("Character is not a
vowel");}
CHAPTER 3
QUESTION 4
String x=jTextField1.getText();
switch (x)
{
case "a":;
case "e":;
case "i":;
case "o":;
case "u":;
case "A":;
case "E":;
case "I":;
case "O":;
case "U":jLabel2.setText("YES THE CHARACTER
IS VOWEL");break;
default :jLabel2.setText("NO THE CHARACTER IS
NOT VOWEL");
}
CHAPTER 3
QUESTION 6
double Tc=0,Tf=0;
if (jRadioButton1.isSelected())
{Tc=Double.parseDouble(jTextField1.getText());
Tf=(Tc*9/5)+32;
jTextField2.setText(""+Tf);
}
else if (jRadioButton2.isSelected())
{Tf=Double.parseDouble(jTextField2.getText());
Tc=(Tf-32)*5/9;
jTextField1.setText(""+Tc);
}
else

JOptionPane.showMessageDialog(this,"please
select the conversion");
CHAPTER 3
QUESTION 7
double value,newvalue=0;

value = Double.parseDouble(jTextField1.getText());

if(jComboBox1.getSelectedIndex()==1)

jLabel2.setText("kg");

jLabel4.setText("g");

newvalue = value*1000;

else if(jComboBox1.getSelectedIndex()==2)

jLabel2.setText("l");

jLabel4.setText("ml");

newvalue = value*1000;

else if(jComboBox1.getSelectedIndex()==3)

jLabel2.setText("Rs.");

jLabel4.setText("p");

newvalue = value*100;

else

JOptionPane.showMessageDialog(this,"please select the conversion");

jTextField2.setText(""+newvalue);
CHAPTER 3
QUESTION 8
double net=0,qty;

qty=Double.parseDouble(jTextField3.getText());

if (jRadioButton1.isSelected())

net=170;

else if(jRadioButton2.isSelected())

net=220;

else

JOptionPane.showMessageDialog(this,"please select the book


code");

if(jRadioButton3.isSelected())

net = net-net*0.25;

else if(jRadioButton4.isSelected())

net = net-net*0.2;

else if(jRadioButton5.isSelected())

net = net-net*0.05;

net=qty*net;

jTextField4.setText(""+net);
CHAPTER 3
QUESTION 9
double bs,hra=0,da=0,gs=0,ns=0;

bs=Double.parseDouble(jTextField6.getText());

if(bs>=10000)

{da=0.25;

hra=0.3;

else if(bs>=20000)

{da=0.25;

hra=0.32;

else if(bs>=40000)

{da=0.35;

hra=0.37;

else

JOptionPane.showMessageDialog(this,"Please enter valid basic salary");

gs=bs+da*bs+hra*bs;

ns=gs-gs*0.1;

jTextField7.setText(""+hra);

jTextField8.setText(""+da);

jTextField9.setText(""+gs);

jTextField10.setText(""+ns);
S.NO NAME DATE REMARKS
Q.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.
Q.2-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.
Q.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.
Q.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.
Q.6-Design a GUI application in java to convert temperature from Celsius
to Fahrenheit or vice versa using radio buttons and two text fields
Q.7-Design a GUI application in java to convert kilograms into grams,
litres into milliliters, rupees into paisa using combobox and text fields.
Q.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%
Q.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.
CHAPTER 3
QUESTION 4
String x=jTextField1.getText();
if (x.equals("a") || x.equals("e") ||
x.equals("i") || x.equals("o") ||
x.equals("u") ||
x.equals("A") || x.equals("E") ||
x.equals("I") || x.equals("O") ||
x.equals("U"))
{ jLabel2.setText("Character is a
vowel");}
else
{ jLabel2.setText("Character is not a
vowel");}

You might also like