Java

Moderators: zibadian
Number of threads: 7836
Number of posts: 18235

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
need to add a gui to this calc Posted by ibi2305 on 27 Feb 2013 at 1:12 AM
Hi i am just wondering if someone can help me add a gui to this code. It just needs to be a very basic one. much appreciated.

import java.util.*;

public class Calculator{

int Num1,Num2;
int Choice;
int Result;
int ch;

Scanner keyboard = new Scanner (System.in);
public void Calc(){


System.out.println("Enter first number: ");
Num1 = keyboard.nextInt();
System.out.println("Enter second number: ");
Num2 = keyboard.nextInt();
System.out.println("MENU.");
System.out.println("1. Addition.");
System.out.println("3. Multiplication.");
System.out.println("2. Subtraction.");
System.out.println("4. Division.");
System.out.println("5. Exit...");
System.out.println("Enter Your Choice.");
Choice = keyboard.nextInt();
switch(Choice){

case 1: Result = Num1 + Num2;
System.out.println("the added result is: " + Result);
break;
case 2: Result = Num1 - Num2;
System.out.println("the subtracted result is: " + Result);
break;
case 3: Result = Num1 * Num2;
System.out.println("the multiplied result is: " + Result);
break;
case 4: Result = Num1/Num2;
System.out.println("the divided resul is: " + Result);
break;
}
}
}

public class MainCalc{

public static void main(String[] args){
Calculator calc = new Calculator();
calc.Calc();

}
}



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.