Documente Academic
Documente Profesional
Documente Cultură
tan;
import javax.swing.*;
public class SimpleCalculator extends JFrame{
//declare the components
private JLabel lblNum1=new JLabel("First No. : ");
private JLabel lblNum2=new JLabel("Second No. : ");
private JLabel lblNum3=new JLabel("Result : ");
private JTextField txtNum1=new JTextField();
private JTextField txtNum2=new JTextField();
private JButton btnAdd=new JButton("ADD");
private JButton btnSub=new JButton("SUBTRACT");
private JButton btnMul=new JButton("MULTIPLY");
private JButton btnDiv=new JButton("DIVIDE");
private JButton btnRes=new JButton("RESET");
private JButton btnEx=new JButton("EXIT");
private JPanel panel=new JPanel();
public SimpleCalculator () {
//define the frame
super("Simple Calculator GUI");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(400,300);
this.setLocation(100,50);
this.setVisible(true);
//define the components
this.lblNum1.setSize(150,20);
this.lblNum1.setLocation(50,20);
this.lblNum2.setSize(150,20);
this.lblNum2.setLocation(50,50);
this.lblNum3.setSize(150,20);
this.lblNum3.setLocation(50,80);
this.txtNum1.setSize(150,20);
this.txtNum1.setLocation(200,20);
this.txtNum2.setSize(150,20);
this.txtNum2.setLocation(200,50);
this.btnAdd.setSize(100,20);
this.btnAdd.setLocation(150,110);
this.btnSub.setSize(100,20);
this.btnSub.setLocation(250,110);
this.btnMul.setSize(100,20);
this.btnMul.setLocation(150,150);
this.btnDiv.setSize(100,20);
this.btnDiv.setLocation(250,150);
this.btnRes.setSize(100,20);
this.btnRes.setLocation(150,190);
this.btnEx.setSize(100,20);
this.btnEx.setLocation(250,190);
this.setContentPane(panel);
//add components to the frame
this.getContentPane().add(lblNum1);
this.getContentPane().add(lblNum2);
this.getContentPane().add(lblNum3);
this.getContentPane().add(txtNum1);
this.getContentPane().add(txtNum2);
this.getContentPane().add(btnAdd);
this.getContentPane().add(btnSub);
this.getContentPane().add(btnMul);
this.getContentPane().add(btnDiv);
this.getContentPane().add(btnRes);
this.getContentPane().add(btnEx);
}
}
----------------------------------------------
package lab11.simple.calculator.gui.tan;
public class Student {
package lab3.payslip.version2.tan;
import java.io.*;
import java.text.*;
double gross,otpay,netpay,withtax,taxrate;
String paygrade = " ";
System.out.print("Employee name : ");
String name=br.readLine();
System.out.print("Basic salary : ");
float salary=Float.parseFloat(br.readLine());
System.out.print("No. of OT hours : ");
double hours=Double.parseDouble(br.readLine());
if (salary>=10000 && salary<15000){
paygrade = "A";
taxrate=0.10;}
else if (salary>=15000 && salary<20000) {
paygrade = "B";
taxrate= 0.10;}
else if (salary>=20000 && salary<25000) {
paygrade = "A";
taxrate=0.15;}
else if (salary>=25000 && salary<30000) {
paygrade = "B";
taxrate=0.15;}
else if (salary>=30000 && salary<35000) {
paygrade = "A";
taxrate=0.20;}
else if (salary>=35000 && salary<40000) {
paygrade = "B";
taxrate=0.20;}
else if (salary>=40000 && salary<45000) {
paygrade = "A";
taxrate=0.25;}
else if (salary>=45000 && salary<50000) {
paygrade = "B";
taxrate=0.25;}
else if (salary>=50000 && salary<55000) {
paygrade = "A";
taxrate=0.30;}
else {
paygrade = "B";
taxrate=0.30;}
otpay=hours*(0.01*salary);
gross=salary + otpay;
withtax= gross*taxrate;
netpay= gross-withtax;
System.out.println("Employee Name : " + name);
System.out.println("Basic Salary : " + df.format(salary));
System.out.println("Pay Grade : " + paygrade);
System.out.println("No. of OT Hours : " + ddff.format(hours));
System.out.println("OT Pay : " + df.format(otpay));
System.out.println("Gross Salary : " + df.format(gross));
System.out.println("Withholding tax : " + ddf.format(withtax));
System.out.println("Net Pay : " + df.format(netpay));
}
package lab8.my.first.pkgclass.with.polymorphism.and.inheritance.tan;
import java.io.*;
}
}
--------------------------------
package lab8.my.first.pkgclass.with.polymorphism.and.inheritance.tan;
public ElectronicDevice(){
this.type="";
this.price=0.00;
}
package fraction2;
import java.io.*;
public class FractionMain {
public static void main(String[] args) throws Exception{
BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
Fraction2 solve=new Fraction2();
/*System.out.println("Numerator : " + solve.getNum());
System.out.println("Denominator : " + solve.getDen());*/
System.out.println();
System.out.println("Enter numerator: ");
int num =Integer.parseInt(br.readLine());
System.out.println("Enter denominator: ");
int den =Integer.parseInt(br.readLine());
solve.setNum(num);
solve.setDen(den);
/*System.out.println();
System.out.println("Brand Name : " + watch.getBrandName());
System.out.println("Size : " + watch.getSize());
System.out.println("Type: " + watch.getType());
watch.transmits();*/
/*solve.num=num;
solve.den=den;*/
solve.shownum();
solve.showden();
solve.showfrac();
solve.lowest();
solve.divide();
solve.type();
}
}
package fraction2;
public class Fraction2 {
int num;
int den;
//constructor
public Fraction2(){
this.num=0;
this.den=0;
}
//setters
public void setNum(int num){
this.num=num;
}
public void setDen(int den){
this.den=den;
}
//getters
public int getNum(){
return this.num;
}
public int getDen(){
return this.den;
}
//custom methods
public void shownum (){
System.out.println("Numerator:" + num);
}
public void showfrac (){
System.out.println("Fraction Form:" + num + "/" + den);
}
}
public void lowest(){
int n = num;
int d = den;
while (d!=0) {
int temp = d;
d = n%d;
n = temp;
}
int great = n;
num /= great;
den /= great;
System.out.println("Lowest Term: " + this.num + "/" + this.den);
}
public void type(){
double rem =0.00;
rem=num%den;
if (num>den) {
if (rem==0)
System.out.println("Fraction Type: Whole Number");
else
System.out.println("Fraction Type: Improper Fraction");
}
else if(den>num) {
System.out.println("Fraction Type: Proper Fraction"); }
else {
System.out.println("Invalid"); }
}
}
package fraction2;
public class Fraction2 {
int num;
int den;
double quo = 0.00;
//constructor
public Fraction2(){
this.num=0;
this.den=0;
}
//setters
public void setNum(int num){
this.num=num;
}
public void setDen(int den){
this.den=den;
}
//getters
public int getNum(){
return this.num;
}
public int getDen(){
return this.den;
}
//custom methods
while (d!=0) {
int temp = d;
d = n%d;
n = temp;
}
int great = n;
num /= great;
den /= great;
}
}
package fraction2;
import java.io.*;
public class FractionMain {
public static void main(String[] args) throws Exception{
BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
Fraction2 solve=new Fraction2();
/*System.out.println("Numerator : " + solve.getNum());
System.out.println("Denominator : " + solve.getDen());*/
System.out.println();
System.out.println("Enter numerator: ");
int num =Integer.parseInt(br.readLine());
System.out.println("Enter denominator: ");
int den =Integer.parseInt(br.readLine());
solve.setNum(num);
solve.setDen(den);
/*System.out.println();
System.out.println("Brand Name : " + watch.getBrandName());
System.out.println("Size : " + watch.getSize());
System.out.println("Type: " + watch.getType());
watch.transmits();*/
/*solve.num=num;
solve.den=den;*/
solve.lowest();
}
}
package lab5.seat.reservation.tan;
import java.io.*;
public class SeatReservation {
}
for (int k=0;k<100;k++) {
for(i=0;i<aryseat.length;i++) {
for(j=0;j<aryseat[i].length;j++) {
System.out.print("\t" + aryseat[i][j] + " ");
}
System.out.println("");
}
}
}