Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem: USING JAVA ONLY (using for loops and conditions) Make a Problem that takes two positive integers. A smaller number and bigger number separated by

Problem: USING JAVA ONLY (using for loops and conditions) Make a Problem that takes two positive integers. A smaller number and bigger number separated by a space. Find all of the numbers that consists of all different digits, inclusive, for example 456 counts but 4456 does not because there is two 4's. Assume that the first integer entered (lower number) is less than or equal to the second integer entered (equal or higher). All of the inputs and outputs are within the size of a normal integer.

Sample outputs and inputs:

Input: 5 13

Output: 8

-(counts 6, 7, 8, 9, 10, 11, 12)

Input: 22 22

Output: 0

-(22 is not good because there are two 2's so the output is 0)

Input: 157 157

Output: 1

Input: 10 90

Output: 73

Input: 1234 123456

Output: 33615

Here is My Java Code so far:

import java.util.Scanner;

public class Problem1 {

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner reader=new Scanner(System.in);

// Enter two bounds-Seperated by space

System.out.println("Enter Two Integers (Seperated by Space- Lower then higher):");

String numbers= reader.nextLine();

//Gets the numbers as a String and stores them in variables

int space= numbers.indexOf(" ");

String num1= numbers.substring(0,space);

String num2=numbers.substring(space+1);

//Make the numbers Integers

int number1=Integer.parseInt(num1);

int number2=Integer.parseInt(num2);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions