SHARE
TWEET

Untitled

a guest Feb 22nd, 2020 223 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Name: Ahmed gamal abbas
  3.  * Bench Number;3 section 1;
  4.  * Email: ahmedabbs9@gmail.com
  5.  */
  6. import java.util.*;
  7. public class calc {
  8.  public static void main(String[] args) {
  9.   Scanner objectname = new Scanner(System.in);
  10.  
  11.   float A, B;
  12.   char S;
  13.   float ON = 1;
  14.   do {
  15.    System.out.println("Enter the first Number:");
  16.    A = objectname.nextFloat();
  17.    System.out.println("Enter the second Number:");
  18.    B = objectname.nextFloat();
  19.    System.out.println("Enter the operation (+ , - , * , / , % ) :");
  20.  
  21.    S = objectname.next().charAt(0);
  22.  
  23.    if (S == '+') {
  24.     System.out.println("The answer is " + (A + B));
  25.     //break;
  26.    }
  27.  
  28.    if (S == '-') {
  29.     System.out.println("The answer is " + (A - B));
  30.     //break;
  31.  
  32.    }
  33.    if (S == '*') {
  34.     System.out.println("The answer is " + (A * B));
  35.     //break;
  36.  
  37.    }
  38.    if (S == '/') {
  39.     System.out.println("The answer is " + (A / B));
  40.     //break;
  41.  
  42.    }
  43.    if (S == '%') {
  44.     System.out.println("The answer is " + (A % B));
  45.     //break;
  46.    }
  47.    System.out.println("To Continue Enter any number  ");
  48.    System.out.println("To Exit Enter 0 ");
  49.    ON = objectname.nextFloat();
  50.   }
  51.   while (ON != 0);
  52.  
  53.  }
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top