Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: how can i make the choices 1 2 3 4 to A B C D in java

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation how can i make the choices 1 2 3 4 to A B C D in java

    this are my codes.

    import java.util.*;

    public class test{
    public static void main (String [] args ){
    Scanner input = new Scanner (System.in);
    int b, n1, n2, sum, sub, mul, div, mod;



    System.out.print ("Enter first number: ");
    n1=input.nextInt();
    System.out.print ("Enter second number: ");
    n2=input.nextInt();
    System.out.println("****************************Ch oose an Operation****************************");


    System.out.println("[1] Addition");

    System.out.println("[2] Subtraction");

    System.out.println("[3] Multiplication");

    System.out.println("[4] Division");

    System.out.println("****************************** *********************************************");
    System.out.println("Selected Operation");
    b=input.nextInt();


    if (b==1){
    sum=n1+n2;
    System.out.print("The Sum is :" + n1 + "&" + n2 +" is " + sum );
    }
    else if (b==2){
    sub=n1-n2;
    System.out.print("The sub is :" + n1 + "&" + n2 +" is " + sub );
    }
    else if (b==3){
    mul=n1*n2;
    System.out.print("The mul is :" + n1 + "&" + n2 +" is " + mul );

    }
    else if (b==4){
    div=n1/n2;
    mod=n1%n2;
    System.out.println("The div is :" + n1 + "&" + n2 +" is " + div );
    System.out.println("The mod is :" + n1 + "&" + n2 +" is " + mod );

    }



    }
    }


  2. #2
    Junior Member
    Join Date
    Jul 2013
    Location
    Aurangabad
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how can i make the choices 1 2 3 4 to A B C D in java

    Hi,
    You can compare character with its ASCII code because java permits direct comparision
    as well as all arithmetic operations on character primitive

Similar Threads

  1. How to make a quiz in Java?
    By sly in forum Java Theory & Questions
    Replies: 6
    Last Post: March 18th, 2013, 11:43 AM
  2. Replies: 0
    Last Post: March 2nd, 2013, 07:52 AM
  3. what is the best way to make a game in java.
    By hwoarang69 in forum Java Theory & Questions
    Replies: 0
    Last Post: November 30th, 2012, 11:58 PM
  4. How to create directory in Java?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: May 19th, 2008, 07:43 AM