Question: Read two positive inputs, the first less than the second. 6 0 0 8 4 6 . 4 0 3 9 4 6 0 .
Read two positive inputs, the first less than the second.
qxzqy
Complete this program, prompting the user to enter two positive numbers a and b so that a is less than b
import java.util.Scanner;
public class TwoNumbers
public static void mainString args
Scanner in new ScannerSystemin;
int a;
int b;
do
System.out.printlnEnter two positive integers, the first smaller than the second.";
System.out.printFirst: ;
a innextInt;
System.out.printSecond: ;
b innextInt;
if a b a b
System.out.printlnInvalid input. Please try again.";
while a b a b ;
This line should only be printed when the input is correct
System.out.printlnYou entered a and b;
Not all tests passed.
: Compare output
Output differs. See highlights below.
Special character legend
Input
Your output
Enter two positive integers, the first smaller than the second.
First: Second: Invalid input. Please try again.
Enter two positive integers, the first smaller than the second.
First: Second: You entered and
Expected output
Enter two positive integers, the first smaller than the second.
First:
Second:
Enter two positive integers, the first smaller than the second.
First:
Second:
You entered and
Output a newline using System.out.println
You are missing a newline here.
You are missing a newline here.
: Compare output
Output differs. See highlights below.
Special character legend
Input
Your output
Enter two positive integers, the first smaller than the second.
First: Second: Invalid input. Please try again.
Enter two positive integers, the first smaller than the second.
First: Second: Invalid input. Please try again.
Enter two positive integers, the first smaller than the second.
First: Second: You entered and
Expected output
Enter two positive integers, the first smaller than the second.
First:
Second:
Enter two positive integers, the first smaller than the second.
First:
Second:
Enter two positive integers, the first smaller than the second.
First:
Second:
You entered and
Output a newline using System.out.println
You are missing a newline here.
You are missing a newline here.
You are missing a newline here.
: Compare output
Output differs. See highlights below.
Special character legend
Input
Your output
Enter two positive integers, the first smaller than the second.
First: Second: Invalid input. Please try again.
Enter two positive integers, the first smaller than the second.
First: Second: Invalid input. Please try again.
Enter two positive integers, the first smaller than the second.
First: Second: You entered and
Expected output
Enter two positive integers, the first smaller than the second.
First:
Second:
Enter two positive integers, the first smaller than the second.
First:
Second:
Enter two positive integers, the first smaller than the second.
First:
Second:
You entered and
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
