Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package calculator;
- import java.util.Scanner;
- /**
- *
- * @author yoshi
- */
- public class Main {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- float newnum;
- float num1;
- int sign;
- float num2;
- Scanner input = new Scanner ( System.in );
- System.out.printf("enter the first number");
- num1 = input.nextFloat();
- System.out.printf("enter the second number");
- num2 = input.nextFloat();
- System.out.printf("enter the sign 1) multiply 2) divide 3) add 4) subtract 5) power ^");
- sign = input.nextInt();
- newnum = calcs( num1, num2, sign );
- }
- private static float calcs(float num1, float num2, int sign) {
- throw new UnsupportedOperationException("Not yet implemented");
- float power;
- float newnum;
- switch (sign) {
- case 1:
- newnum = num1 * num2;
- break;
- case 2:
- newnum = num1 / num2;
- break;
- case 3:
- newnum=num1 + num2;
- break;
- case 4:
- newnum=num1 - num2;
- break;
- case 5:
- power = num1;
- for (int x = 1; x < num2; x++ )
- {
- num1 = num1 * power;
- }
- newnum = num1;
- break;
- }
- return
- }
- // TODO code application logic here
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement