/\/\OO please.
Member
- Joined
- Oct 13, 2007
- Sythe Gold
- 0
- Messages
- 77
Code:
//*Z0mg its a*//
//*Calculat0r*//
import java.util.Scanner;
public class Calculator
{
public static void main(String[]args)
{
int num1;
int num2;
int calc1;
double calc2;
Scanner in=new Scanner(System.in);
System.out.println("First number here");
num1=in.nextInt();
System.out.println("What do you want to do? add = 1 subtract = 2 divide = 3 multiply = 4");
calc1=in.nextInt();
System.out.println("Second number here");
num2=in.nextInt();
calc2=0;
if (calc1 == 1)
calc2=(double)num1+num2;
if (calc1 == 2)
calc2=(double)num1-num2;
if (calc1 == 3)
calc2=(double)num1/num2;
if (calc1 == 4)
calc2=(double)num1*num2;
System.out.println("Your answer is " +calc2);
}
}
outcome :
Code:
First number here
1000
What do you want to do? add = 1 subtract = 2 divide = 3 multiply = 4
2
Second number here
500
Your answer is 500.0
question:
the command or however you call it for inputting an int is in.nextInt();
I've tried a few combinations of in.next[whatever]
i just want to know how to input char's so i can make my calc improved
