Q1.
Input the Principal, Rate and Time and calculate the Simple Interest and Amount
private void calculateinterestActionPerformed([Link] evt) {
int prin = [Link] ([Link]());
int rate = [Link] ([Link]());
int time = [Link] ([Link]());
double interest = ( prin * rate * time) / 100;
[Link] ("" + interest);
private void calculateamountActionPerformed([Link] evt) {
int prin = [Link] ([Link]());
int rate = [Link] ([Link]());
int time = [Link] ([Link]());
double interest = ( prin * rate * time) / 100;
double amount = prin + interest;
[Link] ("" + amount);
}
private void exitActionPerformed([Link] evt) {
[Link](0);
// TODO add your handling code here:
}
private void clearActionPerformed([Link] evt) {
[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link](""); }
Q2. Program to find the greater of three numbers
private void grButtonActionPerformed([Link] evt) {
int N1, N2, N3; // Variables to hold three input values.
int max; // Variable to hold maximum value.
N1 = [Link]([Link]());
N2 = [Link]([Link]());
N3 = [Link]([Link]());
if ((N1 > =N2) && (N1 > N3))
max = N1;
else if ((N2 > =N1) && (N2 > N3))
max = N2;
else if ((N3 > N1) && (N3 > N2))
max = N3;
[Link]("The greater number is : " + max);
}
private void exButtonActionPerformed([Link] evt) {
[Link](0);
}
Q3. Application to input a number and display its reverse (using do…while loop)
private void clearActionPerformed([Link] evt) {
[Link] ("");
[Link] ("");// TODO add your handling code here:
}
private void exitActionPerformed([Link] evt) {
[Link](0);
// TODO add your handling code here:
}
private void mirrorimageActionPerformed([Link] evt) {
int a = [Link] ([Link] ());
int b = a; int d=0;
do {
int c = a%10;
d=d*10+c;
a = a/10;
}while(a!=0);
[Link] ("Mirror Image Of " + b + " is " + d);
// TODO add your handling code here:
}
Q4. Enter the Sales and calculate the incentive of a salesman depending on the choice of any one
option of achievement : Maximum Sales – 10% of sales, Customer feedback – 8% of sales, Maximum
Customers- 5% of Sales. (Implementing Button Group)
private void jButton2ActionPerformed([Link] evt) {
// TODO add your handling code here:
[Link](0);
}
private void jButton1ActionPerformed([Link] evt) {
// TODO add your handling code here:
// Declare & initialize variables for storing sales
int sales = 0;
sales = [Link]([Link]());
double incentive = 0.0;
if([Link]()){
incentive = 0.1; //10%
}
if([Link]()){
incentive = 0.08; //8%
}
if([Link]()){
incentive = 0.05; //5%
}
double t = (sales * incentive);
[Link]("" + t);
}
Q5. ABN Shipment Corporation imposes charges to customers for different product. The shipment
company costs for an order in 2 forms : Wholesaler &Retailer. The cost is calculated as below :
No Units Price for wholesaler (per unit) Price for retailer (per unit)
1 – 15 Rs 50/- Rs 60
16 - 20 Rs 45/ Rs 55/
21 - 30 Rs 40/ Rs 50/
31 - 50 Rs 35/ Rs 45/
> 50 Rs 30/ Rs 40/
Special customers are further given a discount of Rs 10%
private void formWindowGainedFocus([Link] evt) {
[Link](false);
[Link](true);
}
private void cmdExitActionPerformed([Link] evt) {
[Link](0);
}
private void cmdCalcActionPerformed([Link] evt) {
int ordUnit; // Order unit
float TCost=0; // Total cost
float Discount = 0 ; // Discount price
ordUnit=[Link]([Link]());
if ([Link]())
{ if (ordUnit >= 1 && ordUnit <= 15)
TCost = ordUnit * 50;
else if (ordUnit >= 16 && ordUnit <= 20)
TCost = ordUnit * 45;
else if (ordUnit >= 21 && ordUnit <= 30)
TCost = ordUnit * 40;
else if (ordUnit >= 31 && ordUnit <= 50)
TCost = ordUnit * 35;
else if (ordUnit > 50)
TCost = ordUnit * 30;
}
else if ([Link]())
{
if (ordUnit >= 1 && ordUnit <= 15)
TCost = ordUnit * 60;
else if (ordUnit >= 16 && ordUnit <= 20)
TCost = ordUnit * 55;
else if (ordUnit >= 21 && ordUnit <= 30)
TCost = ordUnit * 50;
else if (ordUnit >= 31 && ordUnit <= 50)
TCost = ordUnit * 45;
else if (ordUnit > 50)
TCost = ordUnit * 40;
}
if ([Link]())
Discount = TCost * (float)0.1;
[Link]([Link](Discount)); // (i) Displaying discount
TCost=TCost – Discount ;
[Link]([Link](TCost)); // (ii) Displaying Total Cost
}
Q6. Program to input a number & find its factorial (while loop & input dialog box)
import [Link]. JOptionPane;
private void btnFactActionPerformed([Link] evt) {
int num, i = 1;
float fact = 1;
String str = [Link]("Enter positive number to find factorial");
[Link](str);
num = [Link](str);
if (num = = 1)
{
[Link](this, "Factorial is 1");
}
while( i<=num)
{
fact = fact * num;
i = i + 1;
}
[Link]([Link](fact));
}
Q 7. Sagar electronics has the following products with their list price given. The store gives a 10%
discount on every product. However at the time of festival season, the store gives a further
discount of 7%. Note product name is stored in JListBox control.
private void cmdNetActionPerformed([Link] evt) {
float NetPrice;
NetPrice = [Link]([Link]()) - [Link]([Link]());
[Link]([Link](NetPrice));
}
private void cmdListActionPerformed([Link] evt) {
String Product = [Link]().toString();
if ([Link]("Washing Machine")) {
[Link]("12000");
} else if ([Link]("Color Television")) {
[Link]("17000");
} else if ([Link]("Refrigerator")) {
[Link]("18000");
} else if ([Link]("OTG")) {
[Link]("8000");
} else if ([Link]("CD Player")) {
[Link]("14500");
}
}
private void cmdDiscActionPerformed([Link] evt) {
float ProductPrice, Discount;
ProductPrice = [Link]([Link]());
// Calculating Discount Price
if ([Link]())
Discount = ProductPrice * 17 /100;
else
Discount = ProductPrice * 10 /100;
[Link]([Link](Discount));
}
Q8 . Coding to concatenate two string along with the Input & Message Dialog Box.
import [Link]. JOptionPane; // WRITTEN ON TOP
private void jButton1ActionPerformed([Link] evt) {
String str1 = [Link]("Enter first string ");
String str2 = [Link]("Enter second string ");
[Link](this, str1 + " " + str2);
}
Q9. Develop an application using a table to input the data in a text box & add it in the table
Coding
import [Link].*;
private void insertActionPerformed([Link] evt) {
String a = [Link]();
String b = [Link]();
String c = [Link]();
Object[ ] ob = {a,b,c};
DefaultTableModel tm = (DefaultTableModel)[Link]();
[Link](ob);
}
private void clearActionPerformed([Link] evt) {
[Link]("");
[Link]("");
[Link]("");
}