Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package calculator;
  6. import java.util.Scanner;
  7. /**
  8.  *
  9.  * @author yoshi
  10.  */
  11. public class Main {
  12.     /**
  13.      * @param args the command line arguments
  14.      */
  15.  
  16.     public static void main(String[] args) {
  17.         float newnum;
  18.         float num1;
  19.         int sign;
  20.         float num2;
  21.         Scanner input = new Scanner ( System.in );
  22.     System.out.printf("enter the first number");
  23.     num1 = input.nextFloat();
  24.     System.out.printf("enter the second number");
  25.     num2 = input.nextFloat();
  26.     System.out.printf("enter the sign 1) multiply 2) divide 3) add 4) subtract 5) power ^");
  27.     sign = input.nextInt();
  28.     newnum = calcs( num1, num2, sign );
  29.     }
  30.  
  31.     private static float calcs(float num1, float num2, int sign) {
  32.     throw new UnsupportedOperationException("Not yet implemented");
  33.     float power;
  34.         float newnum;
  35.     switch (sign) {
  36.         case 1:
  37.            newnum = num1 * num2;
  38.             break;
  39.         case 2:
  40.            newnum = num1 / num2;
  41.             break;
  42.         case 3:
  43.             newnum=num1 + num2;
  44.             break;
  45.         case 4:
  46.             newnum=num1 - num2;
  47.             break;
  48.         case 5:
  49.             power = num1;
  50.             for (int x = 1; x < num2; x++ )
  51.             {num1 = num1 * power;}
  52.             newnum = num1;
  53.             break;  
  54.         }
  55.     return
  56.     }
  57.    
  58.         // TODO code application logic here
  59.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement