Question: package task 1 ; import java.util.Scanner; public class task 1 { public static void main ( String [ ] args ) { / / Declare

package task1;
import java.util.Scanner;
public class task1{
public static void main(String[] args){
// Declare variables for first input, second input, bigger input, and smaller input, and loop character.
int first, second;
int bigger, smaller;
char loopCondition ='1';
Scanner input = new Scanner(System.in);
//Start loop based on loop condition.
while (loopCondition ='1');
{
//Prompt the user to enter two numbers.
System.out.print("Please enter two numbers: ");
//Read in those two numbers.
first = input.nextInt();
second = input.nextInt();
//Check which number is larger.
if (Math.abs(first)> Math.abs(second));
{
bigger = first;
smaller = second;
}
else
{
smaller = first;
bigger = second;
}
//Prevent dividing by zero errors.
if (bigger =0|| smaller =0);
{
System.out.println("Do not divide by zero!");
}
//Check if two numbers are divisible
else if (bigger % smaller =0)
{
//If so print the divisor.
System.out.printf("%d goes into %d %d times.
", smaller, bigger,bigger/smaller);
}
else
{
//If not, say not divisible
System.out.println("These numbers are not divisible.");
}
//Prompt the user to repeat loop.
System.out.println("To continue type 1");
System.out.println("To exit, type any other character.");
//Take loop condition input and check if its 1
loopCondition = input.next().charAt(0);
}
//Loop again or break out depending on loop condition.
Scanner.close();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!