import java.io.*;
import java.util.*;
class Stac
{
int st_arr[]=new int[100];
int t=-1;
void push(int ele)
{
if(t==99)
{
System.out.println("STACK is Full.\n");
return;
}
st_arr[++t]=ele;
}
int pop()
{
if(t==-1)
{
return -99;
}
return(st_arr[t--]);
}
}
class Post
{
public static void main(String[] args) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Stac s=new Stac();
System.out.println("Enter an postfix expression");
String s1=br.readLine();
StringTokenizer s2=new StringTokenizer(s1);
String a[]=new String[s2.countTokens()];
int j=0;
while(s2.hasMoreTokens())
a[j++]=s2.nextToken();
for(int i=0;i<a.length;i++)
{
if(a[i].equals("+"))
{
int a1=s.pop();
int a2=s.pop();
s.push(a1+a2);
}
else if(a[i].equals("-"))
{
int a1=s.pop();
int a2=s.pop();
s.push(a1-a2);
}
else if(a[i].equals("*"))
{
int a1=s.pop();
int a2=s.pop();
s.push(a1*a2);
}
else if(a[i].equals("/"))
{
int a1=s.pop();
int a2=s.pop();
s.push(a1/a2);
}
else if(a[i].equals("%"))
{
int a1=s.pop();
int a2=s.pop();
s.push(a1%a2);
}
else
{
s.push(Integer.parseInt(a[i]));
}
}
System.out.println("The result is "+s.pop());
}
}
New evolution of the Mouse. In 1980's round ball mouses are invented, then technology introduced Optical mouses. Now upcoming Mouse is named as Evo mouse . No more movement of your hands on placing a physical mouse, Your finger is the pointer . You can use this mouse on any Flat Surface and also it requires very little space. This mouse contains a Power button on the top, Mini USb port . It works with the help of bluetooth and input is taken by the sensor. View this Video to know the functionality of EvoMouse
Comments
Post a Comment