Mar 14, 2015 10:15 AM
(This post was last modified: Mar 16, 2015 02:01 AM by Captain Steve Rogers.)
Made my first Calculator in Java without copying 🤗 🤗 🤗
Next step : With GUI
Please give me some homework( little easy please still beginner )
Source Code :
Output :
![[Image: fab84b7deda1b5746992f7b51f44c9e0.png]](https://i.gyazo.com/fab84b7deda1b5746992f7b51f44c9e0.png)
Special thanks to Viviparous.
Next step : With GUI
Please give me some homework( little easy please still beginner )
Source Code :
Code
import java.util.Scanner;
public class Basics
{
public static void main(String[] args)
{
Scanner obj = new Scanner(System.in);
int a;
System.out.println("1. Addition\n2. Subtraction \n3. Multiplication\n4. Division");
System.out.print("Choose any one and enter the number : ");
a=obj.nextInt();
if(a < 1 || a > 4)
{
System.out.println("Invalid choice");
System .exit( 0 );
}
else
System.out.print("Enter 1st number : ");
int b=obj.nextInt();
System.out.print("Enter 2nd number : ");
int c=obj.nextInt();
switch(a)
{
case 1:
{
System.out.println("Addition is "+(b+c));
break;
}
case 2:
{
System.out.println("Subtraction is "+(b-c));
break;
}
case 3:
{
System.out.println("Multiplication is "+(b*c));
break;
}
case 4:
{
System.out.println("Division is "+(b/c));
break;
}
}
}
}Output :
![[Image: fab84b7deda1b5746992f7b51f44c9e0.png]](https://i.gyazo.com/fab84b7deda1b5746992f7b51f44c9e0.png)
Special thanks to Viviparous.
![[Image: ebisfS8.png]](https://i.imgur.com/ebisfS8.png)


