0% found this document useful (0 votes)
69 views15 pages

By: Kartavya Chitkara

The document contains code for several Java programs that calculate different things: 1) A soccer scoreboard program that allows the user to increment team scores and displays the winner or tie. 2) A student result program that calculates grades and pass/fail status based on subject scores. 3) A day of the week program that displays the day name based on a number input. 4) A math program that calculates square, cube, and square root of a number. 5) A factorial program that calculates the factorial of a number. 6) A sales commission program that calculates commission based on sales amount and rate brackets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views15 pages

By: Kartavya Chitkara

The document contains code for several Java programs that calculate different things: 1) A soccer scoreboard program that allows the user to increment team scores and displays the winner or tie. 2) A student result program that calculates grades and pass/fail status based on subject scores. 3) A day of the week program that displays the day name based on a number input. 4) A math program that calculates square, cube, and square root of a number. 5) A factorial program that calculates the factorial of a number. 6) A sales commission program that calculates commission based on sales amount and rate brackets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

By : Kartavya Chitkara

SOCCER SCORE BOARD


CODE FOR SOCCER SCORE BOARD
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

int g =Integer.parseInt(jTextField1.getText());

g = g+1;

jTextField1.setText(" "+g);

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

int g =Integer.parseInt(jTextField2.getText());

g = g+1;

jTextField2.setText(" "+g);

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

int a =Integer.parseInt(jTextField1.getText());

int b =Integer.parseInt(jTextField2.getText());

if (a>b)

jTextArea1.append("TEAM A IS A WINNER");

else

if (b>a)

jTextArea1.append("TEAM B IS A WINNER");

else

jTextArea1.append("IT A TIE");
}
To calculate the result of Student
Coding To calculate the result of Student
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

t1.setText("");

t2.setText("");

t3.setText("");

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt)

System.exit(0);

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

int eng=Integer.parseInt(t2.getText());

int bst=Integer.parseInt(t3.getText());

int acc=Integer.parseInt(t4.getText());

int ip=Integer.parseInt(t5.getText());

int math=Integer.parseInt(t6.getText());

int total=eng+bst+acc+ip+math;

int p=total/5;

t7.setText(""+total);

t8.setText(""+p);

if(p>=90)

t10.setText("A");
else if(p>=70 && p<90)

t10.setText("b");

else if(p>50 && p<70)

t10.setText("c");

else

t10.setText("d");

if(p>=33)

t9.setText("Pass");

else

t9.setText("Fail");

}
Input number and show the week day
Coding for Input number and show the week day
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { int
no=Integer.parseInt(t1.getText());

switch(no)

case 1:

l2.setText("sunday");

break;

case 2:

l2.setText("Monday");

break;

case 3:

l2.setText("Tuesday");

break;

case 4:

l2.setText("Wednesday");

break;

case 5:

l2.setText("Thursday");

break;

case 6:

l2.setText("Friday");

break;

case 7:

l2.setText("Friday");

break;

default:

l2.setText("invalid day no ") ; }


Cube root and Square Root
Coding For Finding the Cube root and Square Root
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
int n,s,c;
double sr;
n=Integer.parseInt(jTextField1.getText());
s=n*n;
c=n*n*n;
sr=Math.sqrt(n);

jTextField2.setText(""+s);
jTextField3.setText(""+c);
jTextField4.setText(""+sr);
To Find The Factorial
Coding to Find The Factorial

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)


{
int i=1,fact=1,no;

no=Integer.parseInt(jTextField1.getText());

while(i<=no)
{

fact=fact*i;

i++;
}
jTextField2.setText(""+fact);
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)


{
System.exit(0);

}
Calculate commission for the salesman

`
Coding to Calculate commission for the salesman

Sales Commission
Rates

30001 onwards 15 %
22001 - 30000 10%
12001 - 22000 7%
5001- 12000 3%
0 - 5000 0%

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

String txt = txtsal.getText();

double sales, comm;

sales = Double.parseDouble(txt);

if (sales >= 30000)

comm = sales * 0.15;

else

if (sales >= 22000)

comm =sales * 0.10;

else
if (sales >= 12000)

comm = sales * 0.07;

else

if (sales >= 5000)

comm = sales * 0.03;

else

comm = 0;

lbl1.setText ("The Commission is Rs " +comm); }

You might also like