Sie sind auf Seite 1von 14

ASSIGNMENT-1

Practical Record File

Submitted By
PULKIT GOEL
Class: XII-A

Department of Computer Science


Lucknow Public School, Gomti Nagar
Lucknow
ASSIGNMENT-1

Question 1: - Develop a Compound Interest Calculator application as per given


screen snapshot, to calculate total amount for given Amount, Rate of Interest and
Time using (A=P(1+R/100)T ) and Interest I=A-P.

CODE FOR “Calculate” BUTTON-

double pa=Double.parseDouble(jTextField1.getText()); // Principle Amount


double ir=Double.parseDouble(jTextField2.getText()); // Interest Rate
double ti=Double.parseDouble(jTextField3.getText()); // Time
double ta=pa*(Math.pow((1+ir/100),ti)); // Total Amount
jTextField4.setText(""+ta);
double ia=ta-pa; // Interest Amount
jTextField5.setText(""+ia);

Page | 2
ASSIGNMENT-1

CODE FOR “Clear” BUTTON-

jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");

CODE FOR “Close” BUTTON-

System.exit(0);

------------------------------------------------------------------------------------

Page | 3
ASSIGNMENT-1

ASSIGNMENT-2
Question 2: - A Quick Fox Transport Co. wants to develop an application for
calculating amount based on distance and weight of goods.
The charges (Amount) to be calculated as per rates given below: -
Distance Weight Charges Per Km.
>=100 Kg Rs. 5/-
>=500 Km >=10 and <100 Kg Rs. 6/-
<10 Kg Rs. 7/-
<500 km >=100 Kg Rs. 8/-
<100 Kg Rs. 5/-

CODE FOR “Calculate” BUTTON-

String fc=jTextField1.getText(); // From City


String tc =jTextField2.getText(); // To City
double wei=Double.parseDouble(jTextField3.getText()); // Weight
double dis=Double.parseDouble(jTextField4.getText()); // Distance
Page | 4
ASSIGNMENT-1
double amt; // Amount
if(dis>=500 && wei>=100)
{
amt=5*dis;
jTextField5.setText(“”+amt);
}
else if(dis>500 && wei>=10 && wei<100)
{
amt=6*dis;
jTextField5.setText(“”+amt);
}
else if(dis>=500 && wei<10)
{
amt=7*dis;
jTextField5.setText(“”+amt);
}
else if(dis<500 && wei>=100)
{
amt=8*dis;
jTextField5.setText(“”+amt);
}
else if(dis<500 && wei<100)
{
amt=5*dis;
jTextField5.setText(“”+amt);
}
CODE FOR “Exit” BUTTON-

System.exit(0);

-----------------------------------------------------------------------------------

Page | 5
ASSIGNMENT-1

ASSIGNMENT-3
Question 3: - Develop a Java application to print a Pattern for given character
and steps, as per given screen shot.

CODE FOR “Calculate” BUTTON-


char ch=jTextField1.getText().charAt(0); // Character
int st=Integer.parseInt(jTextField2.getText()); // Steps
for(int i=1;i<=st;i++)
{
for(int j=1;j<=i;j++)
{
jTextArea1.append(""+ch);
Page | 6
ASSIGNMENT-1
}
jTextArea1.append("\n");
}

CODE FOR “Clear” BUTTON-

jTextArea1.setText("");
jTextField1.setText("");
jTextField2.setText("");

----------------------------------------------------------------------------------------

Page | 7
ASSIGNMENT-1

ASSIGNMENT-4
Question 4: - Develop an application to compute the sum of digits for given
number.

CODE FOR “Sum” BUTTON-


int num=Integer.parseInt(jTextField1.getText()); // Number
int rem=0,sum=0;
while(num>0)
{
rem=num%10;
sum=sum+rem;
num=num/10;
}
Page | 8
ASSIGNMENT-1
jTextField2.setText(Integer.toString(sum));
CODE FOR “Exit” BUTTON-
System.exit(0);
-------------------------------------------------------------------------------------

ASSIGNMENT-5
Question 5: - Develop a Prime Number Generator Application which generates
Prime numbers for given range. Prime numbers are those numbers which are
divisible by one or itself only.

CODE FOR “Generate” BUTTON-


int lr=Integer.parseInt(jTextField1.getText()); // Lower Range
int up=Integer.parseInt(jTextField2.getText()); // Upper Range
int status,I;

Page | 9
ASSIGNMENT-1
for(;lr<=up;lr++)
{
status=0;
for(i=2;i<=lr/2;i++)
{
if(lr%i==0)
{
status++;
break;
}
}
if(status==0)
{
jTextArea1.append(“\n”+lr);
}
}
CODE FOR “Exit” BUTTON-
System.exit(0);

-----------------------------------------------------------------------------------------------

Page | 10
ASSIGNMENT-1

Table Joining
 Consider the following tables Course and Student
table.
 Table name- Course

 Table name- Student

Question 1: - Display course name and student name from the above table by
using equi-join.

Page | 11
ASSIGNMENT-1

Question 2: - Write a query to display


course name and student name whose course ID is greater than 200.

Question 3: -Natural join

Page | 12
ASSIGNMENT-1

Question 4: -Left join

Page | 13
ASSIGNMENT-1
Question 5: -Right join

Page | 14

Das könnte Ihnen auch gefallen