Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
[JAVA] Simple Calculator [Command Line]
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Hindi" data-source="post: 257362" data-attributes="member: 26187"><p>As the title, Says;</p><p></p><p>Command line calculator written in java in about 10 minutes by me, here we go;</p><p></p><p><img src="http://i.imgur.com/e22Q90M.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p></p><p>[PHP]import java.util.Scanner;</p><p></p><p>class apples {</p><p> public static void main(String args[])</p><p> {</p><p> int a,b;</p><p> String c;</p><p> </p><p> Scanner choice = new Scanner(System.in);</p><p> </p><p> System.out.println("Operation Choices [Addition,Subtraction,Multiplication,Division] :: ");</p><p> c = choice.nextLine();</p><p> </p><p> System.out.println("Number 1 ::");</p><p> a = choice.nextInt();</p><p> System.out.println("Number 2 :: ");</p><p> b = choice.nextInt();</p><p> </p><p> switch(c)</p><p> {</p><p> case "Addition":</p><p> int d = a+b;</p><p> System.out.printf("Addition of %d & %d is %d",a,b,d);</p><p> break;</p><p> case "Subtraction":</p><p> int x = a-b;</p><p> System.out.printf("Addition of %d & %d is %d",a,b,x);</p><p> break;</p><p> case "Multiplication":</p><p> int y = a*b;</p><p> System.out.printf("Addition of %d & %d is %d",a,b,y);</p><p> break;</p><p> </p><p> case "Division":</p><p> int z = a/b;</p><p> System.out.printf("Addition of %d & %d is %d",a,b,z);</p><p> break;</p><p> default :</p><p> System.out.println(" Enter a proper choice faggot!");</p><p> break;</p><p> }</p><p> }</p><p>}[/PHP]</p><p></p><p>May not be that useful, But I thought it'd be nice to share it so yep.</p></blockquote><p></p>
[QUOTE="Hindi, post: 257362, member: 26187"] As the title, Says; Command line calculator written in java in about 10 minutes by me, here we go; [IMG]http://i.imgur.com/e22Q90M.png[/IMG] [PHP]import java.util.Scanner; class apples { public static void main(String args[]) { int a,b; String c; Scanner choice = new Scanner(System.in); System.out.println("Operation Choices [Addition,Subtraction,Multiplication,Division] :: "); c = choice.nextLine(); System.out.println("Number 1 ::"); a = choice.nextInt(); System.out.println("Number 2 :: "); b = choice.nextInt(); switch(c) { case "Addition": int d = a+b; System.out.printf("Addition of %d & %d is %d",a,b,d); break; case "Subtraction": int x = a-b; System.out.printf("Addition of %d & %d is %d",a,b,x); break; case "Multiplication": int y = a*b; System.out.printf("Addition of %d & %d is %d",a,b,y); break; case "Division": int z = a/b; System.out.printf("Addition of %d & %d is %d",a,b,z); break; default : System.out.println(" Enter a proper choice faggot!"); break; } } }[/PHP] May not be that useful, But I thought it'd be nice to share it so yep. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
[JAVA] Simple Calculator [Command Line]
Top