# Thread: i'm trying to make a calculator program with if else statement...

1. Member
Join Date
Jan 2014
Location
Iloilo, Philippines
Posts
5
Rep Power
0

## i'm trying to make a calculator program with if else statement...

hi guys sorry about bothering you... i've tried youtube for help since im practically clueless how to do stuff with java...

Java Code:
```import javax.swing.*;
import java.util.Scanner;
import javax.swing.JFrame;

public class OrderCalc {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame aFrame = new JFrame("OrderCalc");
aFrame.setSize(500,250);
aFrame.setVisible(true);
}

public static void main (String[] args) {
Scanner Order = new Scanner(System.in);
System.out.println("Enter First Order:");
fnum = Order.nextDouble();
System.out.println("Enter Second Order:");
snum = Order.nextDouble();
System.out.println("Are there more than 2 orders?")
String a = input.next();
if(a==Yes){
System.out.println("Enter Third Order:");
tnum = Order.nextDouble();
System.out.println("Is This The Last Order?");

if (a==yes){
System.out.println("The Total Amount Would Be:" + answer);
}
else (a==no){
System.out.println("Enter Fourth Order:");
qnum = Order.nextDouble();
System.out.println("Is This The Last Order?");

if (a==yes){
System.out.println("The Total Amount Would Be:" + answer);
}
else (a==no){
System.out.println("Enter Fifth Order:");
pnum = Order.nextDouble();
System.out.println("Is This The Last Order?");

if (a==yes){
System.out.println("The Total Amount Would Be:" + answer);
}
else (a==no){
System.out.println("Enter Sixth Order:");
wnum = Order.nextDouble();
System.out.println("Is This The Last Order?");

if (a==yes){
System.out.println("The Total Amount Would Be:" + answer);
}
else (a==no){
System.out.println("Enter Seventh Order:");
rnum = Order.nextDouble();
}
}

}
}
}
else (a==no){
System.out.println("The Total Amount Would Be:"+ answer);
}
}```

2. Senior Member
Join Date
Jun 2008
Posts
2,568
Rep Power
14

## Re: i'm trying to make a calculator program with if else statement...

Ugh. Create a String array with the words "FIRST", "SECOND", "THIRD", etc, and use a single if block printing your "Enter" statement by indexing into the array (and automatically cutting off once the last element is used).