This commit is contained in:
Simon SAYE BABU 2023-10-25 17:27:30 +02:00
parent d2341e4a24
commit 497a7f856b
3 changed files with 50 additions and 0 deletions

6
DEV IHM/TP2/Synopsis.txt Normal file
View File

@ -0,0 +1,6 @@
Synopsis
le jardinier papé14 separe la partielle
il observe la premiere moitier
il separe la deuxieme parcelle
il change d'avis et reunis les dexu sous parcelle

Binary file not shown.

View File

@ -0,0 +1,44 @@
import java.util.Deque;
import java.util.LinkedList;
public class arithm {
public static void main(String[] args) {
Deque<Object> pile = new LinkedList<>();
Object x;
int a,b;
for (int i = 0; i < args.length; i++)
{
x = args[i];
if (x == "+" || x == "-" || x == "/" || x == "*" )
{
switch (x) {
case "+":
a = (Integer) pile.pop();
b = (Integer) pile.pop();
pile.add(a+b);
break;
case "-":
a = (Integer) pile.pop();
b = (Integer) pile.pop();
pile.add(a-b);
break;
case "/":
a = (Integer) pile.pop();
b = (Integer) pile.pop();
pile.add(a/b);
break;
case "*":
a = (Integer) pile.pop();
b = (Integer) pile.pop();
pile.add(a*b);
break;
}
}
else
{
pile.add(x);
}
}
System.out.println("="+pile.pop());
}
}