Question

import java.util.Scanner; class Main { public static void main(String[] args) { Scanner inp = new Scanner(System.in);...

import java.util.Scanner;
class Main
{
public static void main(String[] args)
{
Scanner inp = new Scanner(System.in);
System.out.print("In:");
int nn = inp.nextInt();
int n0, n1, n2, n3, n4;
  
//Change only the code below
//Set n0, n1, . . . n4 to each digits in nn by replacing
//the blanks _A_, _B_, ect
//Hint: the ones digit of 1234 is 1234%10
// the hundredth digit of 31415 is (31415/100)%10
n0 = _A_;
n1 = _B_;
n2 = _C_;
n3 = _D_;
n4 = _E_;
  
//Print the digits separated by a ,
  
  
  
//Using if statement(s), print YES or NO

Example output #5(

Statement

Given a number between 10 and 99999,

#1 print the 5 digits from left to right separated by a comma.

#2 Compare the digits as you read it from left to right. Print "YES" if the digits are equal or increasing and print "NO" otherwise.

Example input #1

 
 

13547

Example output #1 (NO because 4 is not equal or greater than 5)

 
 

1, 3, 5, 4, 7

 

NO

Example input #2

 
 

246

Example output #2

 
 

0, 0, 2, 4, 6

 

YES

Example input #3

 
 

5676

Example output #3

 
 

0, 5, 6, 7, 6

 

NO

 

Example input #4

 
 

11223

Example output #4

 
 

1, 1, 2, 2, 3

 

YES

Example input #5

 
 

54

Example output #5 (NO because 4 is not greater or equal 5)

 
 

0, 0, 0, 5, 4

 

NO

 
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;
public class Main
{
   public static void main(String[] args)
   {
       Scanner inp = new Scanner(System.in);
       System.out.print("In:");
       int nn = inp.nextInt();
       int n0, n1, n2, n3, n4;

       //Change only the code below
       //Set n0, n1, . . . n4 to each digits in nn by replacing
       //the blanks _A_, _B_, ect
       //Hint: the ones digit of 1234 is 1234%10
       // the hundredth digit of 31415 is (31415/100)%10
       n0 = nn%10;
       n1 = nn/10%10;
       n2 = nn/100%10;
       n3 = nn/1000%10;
       n4 = nn/10000%10;
       System.out.println(n4+" "+n3+" "+n2+" "+n1+" "+n0);
       if(n0>=n1 && n1>=n2 && n2>=n3 &&n3>=n4)
           System.out.println("YES");
       else
           System.out.println("NO");

   }
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner inp = new Scanner(System.in);...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Import java.util.*; public class PairFinder { public static void main(String[] args) { Scanner sc...

    import java.util.*; public class PairFinder { public static void main(String[] args) { Scanner sc = new Scanner(System.in);    // Read in the value of k int k = Integer.parseInt(sc.nextLine());    // Read in the list of numbers int[] numbers; String input = sc.nextLine(); if (input.equals("")) { numbers = new int[0]; } else { String[] numberStrings = input.split(" "); numbers = new int[numberStrings.length]; for (int i = 0; i < numberStrings.length; i++) { numbers[i] = Integer.parseInt(numberStrings[i]); } }    System.out.println(findPairs(numbers, k)); }    //method that...

  • import java.util.Scanner; public class Lab6d { public static void main(String[] args) {    Scanner scnr =...

    import java.util.Scanner; public class Lab6d { public static void main(String[] args) {    Scanner scnr = new Scanner(System.in); // TODO: get user choice    // TODO: call printTable method passing choice as the parameter    } public static void printTable(int stop) { // TODO: print header    // TODO: loop to print table rows up to stop value    } Write a Java program where the main () method prompts the user to select an integer value between 1 and...

  • import java.util.Scanner; public class TempConvert { public static void main(String[] args) { Scanner scnr = new...

    import java.util.Scanner; public class TempConvert { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); //ask the user for a temperature System.out.println("Enter a temperature:"); double temp = scnr.nextDouble(); //ask the user for the scale of the temperature System.out.println("Is that Fahrenheit (F) or Celsius (C)?"); char choice = scnr.next().charAt(0); if(choice == 'F') { //convert to Celsius if given temperature was Fahrenheit System.out.println(temp + " degrees Fahrenheit is " + ((5.0/9) * (temp-32)) + " degrees Celsius"); } else {...

  • import java.util.Scanner; public class creditScore { public static void main(String[]args) { // declare and initialize variables...

    import java.util.Scanner; public class creditScore { public static void main(String[]args) { // declare and initialize variables int creditScore; double loanAmount,interestRate,interestAmount; final double I_a = 5.56,I_b = 6.38,I_c = 7.12,I_d = 9.34,I_e = 12.45,I_f = 0; String instructions = "This program calculates annual interest\n"+"based on a credit score.\n\n"; String output; Scanner input = new Scanner(System.in);// for receiving input from keyboard // get input from user System.out.println(instructions ); System.out.println("Enter the loan amount: $"); loanAmount = input.nextDouble(); System.out.println("Enter the credit score: "); creditScore...

  • import java.util.Scanner; public class TwelveDays {    public static void main(String[] args)    {       final...

    import java.util.Scanner; public class TwelveDays {    public static void main(String[] args)    {       final int MAX = 12;       int lastDay = 0; //last day for the song, user will update       Scanner scan = new Scanner(System.in);       //Get the last day and use input validation //Begin 1st while       {       }                     int day = 1;      //loop control variable for song verses       //Begin 2nd while       {          //Output: "On the" + day...

  • import java.util.Scanner; public class SCAN { public static void main(String[ ] args) { int x, y,...

    import java.util.Scanner; public class SCAN { public static void main(String[ ] args) { int x, y, z; double average; Scanner scan = new Scanner(System.in); System.out.println("Enter an integer value"); x = scan.nextInt( ); System.out.println("Enter another integer value"); y = scan.nextInt( ); System.out.println("Enter a third integer value"); z = scan.nextInt( ); average = (x + y + z) / 3; System.out.println("The result of my calculation is " + average); } } What is output if x = 0, y = 1 and...

  • import java.util.Scanner; import java.io.File; public class Exception2 {        public static void main(String[] args) {              ...

    import java.util.Scanner; import java.io.File; public class Exception2 {        public static void main(String[] args) {               int total = 0;               int num = 0;               File myFile = null;               Scanner inputFile = null;               myFile = new File("inFile.txt");               inputFile = new Scanner(myFile);               while (inputFile.hasNext()) {                      num = inputFile.nextInt();                      total += num;               }               System.out.println("The total value is " + total);        } } /* In the first program, the Scanner may throw an...

  • //LinkedList import java.util.Scanner; public class PoD {    public static void main( String [] args )...

    //LinkedList import java.util.Scanner; public class PoD {    public static void main( String [] args ) { Scanner in = new Scanner( System.in ); LinkedList teamList = new LinkedList(); final int TEAM_SIZE = Integer.valueOf(in.nextLine()); for (int i=0; i<TEAM_SIZE; i++) { String newTeamMember = in.nextLine(); teamList.append(newTeamMember); } while (in.hasNext()) { String removeMember = in.nextLine(); teamList.remove(removeMember); }    System.out.println("FINAL TEAM:"); System.out.println(teamList); in.close(); System.out.print("END OF OUTPUT"); } } =========================================================================================== //PoD import java.util.NoSuchElementException; /** * A listnked list is a sequence of nodes with...

  • package bigIntegerPackage; import java.util.Scanner; public class BigIntMathTesterOne {    private static Scanner keyboard = new Scanner(System.in);...

    package bigIntegerPackage; import java.util.Scanner; public class BigIntMathTesterOne {    private static Scanner keyboard = new Scanner(System.in);    /* *    * @param args    */    public static void main(String[] args)    { /** * Sample valid input and resulting output *    "44444444445555555555666666666677777777770000000000" * stores ["4","4","4","4","4","4","4","4","4","4","5","5","5","5","5","5","5","5","5","5","6","6","6","6","6","6","6'<'6","6","6","7","7","7","7","7","7","7","7","7","7","0","0","0","0","0","0","0","0","0","0"] in ArrayList and sets the value to positive *returns string "44444444445555555555666666666677777777770000000000" * "100000" stores ["1","0","0","0","0","0"] in ArrayList and sets the value to positive *returns string "100000" *"+0" stores ["0"] in ArrayList and sets...

  • import java.util.Scanner; public class TriangleMaker {    public static void main(String[] args) {        //...

    import java.util.Scanner; public class TriangleMaker {    public static void main(String[] args) {        // TODO Auto-generated method stub        System.out.println("Welcome to the Triangle Maker! Enter the size of the triangle.");        Scanner keyboard = new Scanner(System.in);    int size = keyboard.nextInt();    for (int i = 1; i <= size; i++)    {    for (int j = 0; j < i; j++)    {    System.out.print("*");    }    System.out.println();    }    for (int...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT