Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Did it in C how I can make it in JAVA (https://www.askmehelpdesk.com/showthread.php?t=606244)

  • Oct 23, 2011, 02:18 PM
    HRida
    Did it in C how I can make it in JAVA
    //the question is below at final

    Package assignment2_1;
    Import java.util.Scanner;
    Public class Assignment2_1
    { public static void main(String[] args)
    {
    System.out.println("Enter your 3 numeric values");

    System.out.println("Note: this program purpose is to find the minimum and maximum value of what you enter");
    Scanner scan= new Scanner(System.in);

    int firstNumericValue,secondNumericValue,thirdNumericV alue;

    System.out.println("Enter your first numeric value:");
    firstNumericValue=scan.nextInt();

    System.out.println("Enter your second numeric value:");
    secondNumericValue=scan.nextInt();

    System.out.println("Enter your third numeric value:");
    thirdNumericValue=scan.nextInt();
    int max,min;
    if((firstNumericValue>secondNumericValue)&&(firstN umericValue>thirdNumericValue)&&(secondNumericValu e>thirdNumericValue))
    {
    max=firstNumericValue;
    min=thirdNumericValue;
    }
    Else if((firstNumericValue>secondNumericValue)&&(firstN umericValue>thirdNumericValue)&&(secondNumericValu e<thirdNumericValue))
    {
    max=firstNumericValue;
    min=secondNumericValue;
    }
    Else if((secondNumericValue>firstNumericValue)&&(second NumericValue>thirdNumericValue)&&(firstNumericValu e>thirdNumericValue))
    {
    max=secondNumericValue;
    min=thirdNumericValue;
    }
    Else if((secondNumericValue>firstNumericValue)&&(second NumericValue>thirdNumericValue)&&(firstNumericValu e<thirdNumericValue))
    {
    max=secondNumericValue;
    min=firstNumericValue;
    }
    Else if((thirdNumericValue>firstNumericValue)&&(thirdNu mericValue>secondNumericValue)&&(firstNumericValue >secondNumericValue))
    {
    max=thirdNumericValue;
    min=secondNumericValue;
    }
    Else if((thirdNumericValue>firstNumericValue)&&(thirdNu mericValue>secondNumericValue)&&(firstNumericValue <secondNumericValue))
    {
    max=thirdNumericValue;
    min=firstNumericValue;
    }
    If(max%min==0){System.out.println(max "divisible by" min);}
    Else {System.out.println("The #s are not divisible by each others.");}
    //this is like C how I can make it in java ?
    }
    }

  • All times are GMT -7. The time now is 09:13 PM.