Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Application {
- public static void main(String[] args) {
- Scanner reader = new Scanner(System.in);
- System.out.print("Type a number: ") ;
- int a = Integer.parseInt(reader.nextLine() ) ;
- System.out.print("Type another number: ") ;
- int b = Integer.parseInt(reader.nextLine() ) ;
- System.out.print("Choose type of calculation: ");
- String cal = reader.nextLine() ;
- System.out.println(" ");
- int plus = a + b ;
- int keer = a * b ;
- int min = a - b ;
- double deel = (double) a / b;
- if (cal.equals("+")) {
- System.out.println(a + " + " + b + " = " + plus);
- } else if (cal.equals("-")) {
- System.out.println(a + " - " + b + " = " + min);
- } else if (cal.equals("*")) {
- System.out.println(a + " * " + b + " = " + keer);
- } else if (cal.equals("/")) {
- System.out.println(a + " / " + b + " = " + deel);
- } else {
- System.out.println("That does not exist!");
- }
- System.out.println(" ");
- System.out.println("The other anwers are: ");
- System.out.println(a + "+" + b + "=" + plus + ", ");
- System.out.println(a + "-" + b + "=" + min + ", ");
- System.out.println(a + "*" + b + "=" + keer + ", ");
- System.out.println(a + "/" + b + "=" + deel + ".");
- }
- }
Add Comment
Please, Sign In to add comment