Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sandeep parashar
programing
1 Answer(s)      3 years ago
Posted in : Java Server Faces Questions


write a program to input a number find & print the middle digit if no of digit are odd other wise print the average of middle two digit.


Advertisement
View Answers

December 28, 2011 at 11:54 AM


import java.util.*;

class InputNumber 
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter number: ");
        int num=input.nextInt();
        int largest=0;
        while( num > 0 ){
        int digit = num % 10;
        num = num / 10;
        if (digit > largest) 
        largest = digit;
        }
        System.out.println("Highest digit is: "+largest);
        }
    }


Related Tutorials/Questions & Answers:
Java programing
Java programing   need help wrting this Write a program that has an array of 5 Strings, and determines which ones are palindromes (letter-case does not matter). thanks
socket programing in servlet
socket programing in servlet  give me a example to write socket programing in servlet
Advertisements
programing question
programing question  how do i use loops(for,while) to add components in java   Hi Friend, The below code might help you. import java.awt.*; import javax.swing.*; class TextFieldArray extends JFrame{ JLabel l[]=new
Programing Help - Java Beginners
Programing Help  how to design a filebrowser in java "witout using Swing
SOCKET PROGRAMING IN THE JAVA FOR NETWORKING CONCEPT
SOCKET PROGRAMING IN THE JAVA FOR NETWORKING CONCEPT  I WANT TO KNOW ABOUT THE JAVA SOCKET PROGRAMING FROM BASIC LEVEL AND HOW CAN I WORK ON IT I KNOW THE JAVA PROGRAMING.SO PLEASE HELP ME HOW CAN I DO SOCKET PROGRAMING
Java programing help
Java programing help  Can you help me create this program? Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed). As they enter the data, assign
javascript programing error - JSP-Servlet
javascript programing error  hi deepak i m using explorer to run javascript program in this there is no option to check error will u plz tell me the way to check error in explorer as we can check with mozila
java programing problem - Java Beginners
java programing problem  Create a class named Movie that can be used with your video rental business. The Movie class should track the Motion picture Association of America rating , ID Number, and movie title with appropriate
guys,, need help,, in java programing,, arrays
guys,, need help,, in java programing,, arrays  create a program where you will input 10 numbers and arrange it in ascending way using arrays
Advertisements
 

 

 

DMCA.com