simple calculator making project in java.

sadat
0

package com.mahmud;

import jdk.dynalink.beans.StaticClass;

import java.util.Scanner;

public class Main {
static int sum(int num4, int num5) {
return num4+num5;
}

public static void main(String[] args) {


float num1,num2;

int [] sadat = {1,3,5,6,7,9};
for (int value:sadat){
System.out.print(value);

}
System.out.println(" Enter first number");
Scanner scan = new Scanner(System.in);
num1 = scan.nextFloat();

System.out.println("Enter operator");
Scanner scan2 = new Scanner(System.in);
String operator = scan.next();
System.out.println("Enter second number");
num2 = scan.nextFloat();

switch (operator){
case "+":
System.out.print("adding two numbers: ");
System.out.println(num1 + operator + num2);
System.out.println(num1+num2);
break;

case "-":
System.out.print("subtracting two numbers: ");
System.out.println(num1 + operator + num2);
System.out.println(num1-num2);
break;

case "/":
System.out.print("deviding two numbers: ");
System.out.println(num1 + operator + num2);
System.out.println(num1/num2);
break;

case "*":
System.out.print("multiplicating two numbers: ");
System.out.println(num1 + operator + num2);
System.out.println(num1*num2);
break;

default:
System.out.println("Invalid input");



}



}
}


Post a Comment

0Comments

Please Select Embedded Mode To show the Comment System.*