Hello friends,
Today I 'll show you how to make a calculator with java
If You Want To Start Java Programming. Then, First You have To Download Netbeans Or Eclipse IDE
Go To the link
Download Netbeans IDE
From Here Download Netbeans.
Download Java SE for Standard Edition Or If You Want To Work With All Platforms Download All
After Download Install Netbeans IDE
Now Go To File>>New Project>>Java>>Java Application
Now, Give Your Project Name. Here, I am Showing You a Simple Calculator. This is Very Beginning And It will Work in Java Console. It is not A Graphical Software.Later I Will Show You Java Desktop And Mobile Software Making.
So Project Name is Calculator. Click >>Next. A White Window Will be Opned. Remove All Code And Paste This Code
import java.util.Scanner;
public class Calculator {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
double a,b;
System.out.println(“Enter 1st Number=”);
a=input.nextDouble();
System.out.println(“Enter 2nd Number=”);
b=input.nextDouble();
System.out.println(“Enter + For Add=”);
System.out.println(“Enter – For subtract=”);
System.out.println(“Enter * For multiplication=”);
System.out.println(“Enter / For divition=”);
char c;
System.out.println(“Enter Character=”);
c=input.next().charAt(0);
switch(c)
{
case ‘+':
System.out.println(“Addition Is=”+(a+b));
break;
case ‘-‘:
System.out.println(“Subtraction Is=”+(a-b));
break;
case ‘*':
System.out.println(“Multiplication Is=”+(a*b));
break;
case ‘/':
System.out.println(“Divition Is=”+(a/b));
break;
default:
System.out.println(“Invalid Input”);
break;
}
}
}
Now Go to Run And Click Run File. In Below Output Console Your Program Will be Started To Run. Give Two Number. Then Give Operator And You Will Show Your Calculated Output.
Hope for the best... Happy Coddddding
Today I 'll show you how to make a calculator with java
If You Want To Start Java Programming. Then, First You have To Download Netbeans Or Eclipse IDE
Go To the link
Download Netbeans IDE
From Here Download Netbeans.
Download Java SE for Standard Edition Or If You Want To Work With All Platforms Download All
After Download Install Netbeans IDE
Now Go To File>>New Project>>Java>>Java Application
Now, Give Your Project Name. Here, I am Showing You a Simple Calculator. This is Very Beginning And It will Work in Java Console. It is not A Graphical Software.Later I Will Show You Java Desktop And Mobile Software Making.
So Project Name is Calculator. Click >>Next. A White Window Will be Opned. Remove All Code And Paste This Code
import java.util.Scanner;
public class Calculator {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
double a,b;
System.out.println(“Enter 1st Number=”);
a=input.nextDouble();
System.out.println(“Enter 2nd Number=”);
b=input.nextDouble();
System.out.println(“Enter + For Add=”);
System.out.println(“Enter – For subtract=”);
System.out.println(“Enter * For multiplication=”);
System.out.println(“Enter / For divition=”);
char c;
System.out.println(“Enter Character=”);
c=input.next().charAt(0);
switch(c)
{
case ‘+':
System.out.println(“Addition Is=”+(a+b));
break;
case ‘-‘:
System.out.println(“Subtraction Is=”+(a-b));
break;
case ‘*':
System.out.println(“Multiplication Is=”+(a*b));
break;
case ‘/':
System.out.println(“Divition Is=”+(a/b));
break;
default:
System.out.println(“Invalid Input”);
break;
}
}
}
Now Go to Run And Click Run File. In Below Output Console Your Program Will be Started To Run. Give Two Number. Then Give Operator And You Will Show Your Calculated Output.
Hope for the best... Happy Coddddding
0 comments:
Post a Comment