Ajp (22517)
Ajp (22517)
Ajp (22517)
Java technology is widely used for web application development. Based on the object-
oriented concepts and core Java concepts, this course will equip the students with the
required knowledge and skill of the object-oriented programming approach needed for the
development of robust, powerful web applications. Through this course, students will get
hands-on experience with GUI Technologies viz. AWT and Swings, event handling
mechanisms, and network programming. The course also gives coverage to various web
application aspects like Database Interaction, server-side components, and servlets.
Micro-Project Report
The first solid-state electronic calculator was made in the early 1960s. Pocket-sized gadgets
became available in the 1970s, particularly after the Intel 4004, the first microprocessor, was
designed by Intel for the Japanese calculator company Busicom. They later became utilized
generally within the petroleum industry (oil and gas). Modern electronic calculators vary
from affordable, give-away, credit-card-sized models to sturdy desktop models with built-in
printers. They became famous in the mid-1970s as the incorporation of integrated circuits
decreased their size and cost. By the end of that decade, prices had fallen to the point where a
basic calculator was affordable to most and they became familiar in schools. In addition to
general-purpose calculators, there are those created for specific markets. For example, there
are scientific calculators which contain trigonometric and statistical calculations. Some
calculators even have the capacity to do computer algebra. Graphing calculators can be used
to graph functions defined on the real line or higher-dimensional Euclidean space. As of
2016, basic calculators cost little, but scientific and graphing models tend to cost more.
One of the most primal calculators, the abacus is still utilized in some parts of the Far East.
The abacus uses groups of beads to indicate numbers. Like the slide rule, the abacus requires
no source of power. The beads are positioned in several parallel rows and can be rolled up
and down to denote arithmetic operations. It is said that a skilled abacus user can do some
calculations just as fast as a person equipped with a battery-powered calculator. As
calculators became more advanced during the 1970s, they became capable to make
computations involving variables (unknowns). These were the first personal computers.
Today's personal computers can still accomplish such operations, and most are delivered with
a virtual calculator program that actually looks, on screen, like a handheld calculator. The
buttons are actuated by pointing and clicking. Electronic calculators contain a keyboard with
buttons for digits and arithmetical operations; some even contain "00" and "000" buttons to
make larger or smaller numbers more comfortable to enter. Most basic calculators assign only
one digit or operation on each button; however, in more specific calculators, a button can
perform multi-function working with key combinations. Display output Calculators usually
have liquid-crystal displays (LCD) as output in place of historical light-emitting diode (LED)
displays and vacuum fluorescent displays (VFD); details are supplied in the section Technical
improvements.
Program Code :
import java.awt.*;
import java.awt.event.*;
MyCalculator(String frameText)
{
super(frameText);
tempX=TOPX;
y=TOPY+2*(HEIGHT+V_SPACE);
for(int i=0; i<memoryButton.length; i++)
{
memoryButton[i]=new MyMemoryButton(tempX,y,WIDTH,HEIGHT,memoryButtonText[i], this);
memoryButton[i].setForeground(Color.RED);
y+=HEIGHT+V_SPACE;
}
tempX=TOPX+1*(WIDTH+H_SPACE); y=TOPY+1*(HEIGHT+V_SPACE);
for(int i=0;i<specialButton.length;i++)
{
specialButton[i]=new MySpecialButton(tempX,y,WIDTH*2,HEIGHT,specialButtonText[i], this);
specialButton[i].setForeground(Color.RED);
tempX=tempX+2*WIDTH+H_SPACE;
}
int digitX=TOPX+WIDTH+H_SPACE;
int digitY=TOPY+2*(HEIGHT+V_SPACE);
tempX=digitX; y=digitY;
for(int i=0;i<digitButton.length;i++)
{
digitButton[i]=new MyDigitButton(tempX,y,WIDTH,HEIGHT,digitButtonText[i], this);
digitButton[i].setForeground(Color.BLUE);
tempX+=WIDTH+H_SPACE;
if((i+1)%3==0){tempX=digitX; y+=HEIGHT+V_SPACE;}
}
int opsX=digitX+2*(WIDTH+H_SPACE)+H_SPACE;
int opsY=digitY;
tempX=opsX; y=opsY;
for(int i=0;i<operatorButton.length;i++)
{
tempX+=WIDTH+H_SPACE;
operatorButton[i]=new MyOperatorButton(tempX,y,WIDTH,HEIGHT,operatorButtonText[i], this);
operatorButton[i].setForeground(Color.RED);
if((i+1)%2==0){tempX=opsX; y+=HEIGHT+V_SPACE;}
}
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent ev)
{System.exit(0);}
});
setLayout(null);
setSize(FRAME_WIDTH,FRAME_HEIGHT);
setVisible(true);
}
{cl.displayLabel.setText("0.");cl.setClear=false;}
else if(!isInString(cl.displayLabel.getText(),'.'))
cl.displayLabel.setText(cl.displayLabel.getText()+".");
return;
}
int index=0;
try{
index=Integer.parseInt(tempText);
}catch(NumberFormatException e){return;}
if(cl.setClear)
{cl.displayLabel.setText(""+index);cl.setClear=false;}
else
cl.displayLabel.setText(cl.displayLabel.getText()+index);
}
}
cl.setClear=true;
double temp=Double.parseDouble(cl.displayLabel.getText());
if(opText.equals("1/x"))
{
try
{double tempd=1/(double)temp;
cl.displayLabel.setText(MyCalculator.getFormattedText(tempd));}
catch(ArithmeticException excp)
{cl.displayLabel.setText("Divide by 0.");}
return;
}
if(opText.equals("sqrt"))
{
try
{double tempd=Math.sqrt(temp);
cl.displayLabel.setText(MyCalculator.getFormattedText(tempd));}
catch(ArithmeticException excp)
{cl.displayLabel.setText("Divide by 0.");}
return;
}
if(!opText.equals("="))
{
cl.number=temp;
cl.op=opText.charAt(0);
return;
}
switch(cl.op)
{
case '+':
temp+=cl.number;break;
case '-':
temp=cl.number-temp;break;
case '*':
temp*=cl.number;break;
case '%':
try{temp=cl.number%temp;}
catch(ArithmeticException excp)
{cl.displayLabel.setText("Divide by 0."); return;}
break;
case '/':
try{temp=cl.number/temp;}
catch(ArithmeticException excp)
{cl.displayLabel.setText("Divide by 0."); return;}
break;
}
cl.displayLabel.setText(MyCalculator.getFormattedText(temp));
}
}
class MyMemoryButton extends Button implements ActionListener
{
MyCalculator cl;
cl.setClear=true;
double temp=Double.parseDouble(cl.displayLabel.getText());
switch(memop)
{
case 'C':
cl.memLabel.setText(" ");cl.memValue=0.0;break;
case 'R':
cl.displayLabel.setText(MyCalculator.getFormattedText(cl.memValue));break;
case 'S':
cl.memValue=0.0;
case '+':
cl.memValue+=Double.parseDouble(cl.displayLabel.getText());
if(cl.displayLabel.getText().equals("0") || cl.displayLabel.getText().equals("0.0") )
cl.memLabel.setText(" ");
else
cl.memLabel.setText("M");
break;
}
}
}
class MySpecialButton extends Button implements ActionListener
{
MyCalculator cl;
MySpecialButton(int x,int y, int width,int height,String cap, MyCalculator clc)
{
super(cap);
setBounds(x,y,width,height);
this.cl=clc;
this.cl.add(this);
addActionListener(this);
}
static String backSpace(String s)
{
String Res="";
for(int i=0; i<s.length()-1; i++) Res+=s.charAt(i);
return Res;
}
public void actionPerformed(ActionEvent ev)
{
String opText=((MySpecialButton)ev.getSource()).getLabel();
if(opText.equals("Backspc"))
{
String tempText=backSpace(cl.displayLabel.getText());
if(tempText.equals(""))
cl.displayLabel.setText("0");
else
cl.displayLabel.setText(tempText);
return;
}
if(opText.equals("C"))
{
cl.number=0.0; cl.op=' '; cl.memValue=0.0;
cl.memLabel.setText(" ");
}
cl.displayLabel.setText("0");cl.setClear=true;
}
}
Outputs of Micro-Project :
3.0 Skill Developed