Question

In: Computer Science

Write a complete Java program to solve the following problem. Read two positive integers from the...

Write a complete Java program to solve the following problem.

Read two positive integers from the user and print all the multiple of five in between them. You can assume the second number is bigger than the first.

For example if the first number is 1 and the second number is 10, then your program should output

5 10

Java must be grade 11 work easy to understand and not complicated code

Solutions

Expert Solution

/*If you any query do comment in the comment section else like the solution*/

import java.util.Scanner;
class MultipleOfFive {
    public static void main(String[]args) {
        Scanner sc = new Scanner(System.in);
        int low, high;
        System.out.println("Enter two numbers: ");
        low = sc.nextInt();
        high = sc.nextInt();
        //Running a loop starting from low to high
        while(low <= high) {
            //if a number is divisible by 5 then low divided by five will give remainder zero
            if(low % 5 == 0) {
                System.out.print(low + " ");
            }
            low++;
        }
    }
}


Related Solutions

java Problem 3: An Interesting Problem Write a program that accepts two positive integers: a deposited...
java Problem 3: An Interesting Problem Write a program that accepts two positive integers: a deposited amount of money and an interest rate, as an annual percentage rate. Your program will calculate the number of years that will take for the account balance to reach $1, 000,000. You can assume that the initial deposit is less than $1,000,000 Input The input will begin with a single line containing T , the number of test cases to follow. The remaining lines...
Java Program Problem // Description: Read five positive integers and average them. // Enter a negative...
Java Program Problem // Description: Read five positive integers and average them. // Enter a negative integer to end the program. import java.util.Scanner; public class Lab5 { public static void main (String args[]) {        Scanner sc;        sc = new Scanner(System.in);    final int MAX_NUMS = 5;        int num;       // variable to store the number        int sum;   // variable to store the sum        int count;    // variable to store...
Write MIPs program that will read two integers from the user and compute for the sum...
Write MIPs program that will read two integers from the user and compute for the sum and difference of the two integers. Ask the user whether he wants to repeat the program : "[Y/y] / [N/n] ?".
Using Java, write a program that takes in two integers from the keyboard called m and...
Using Java, write a program that takes in two integers from the keyboard called m and n, where m > n. Your program should print the first m natural numbers (m..1) downwards in n rows.
JAVA PROGRAM Write program that will prompt user generate two random integers with values from 1...
JAVA PROGRAM Write program that will prompt user generate two random integers with values from 1 to 10 then subtract the second integer from the first integer. Note, if the second integer is greater than the first integer, swap the two integers before making the subtraction.Then prompt user for the answer after the subtraction. If the answer is correct, display “Correct”otherwise display “Wrong”.You will need to do this in a loop FIVE times and keep a count of how many...
Write a complete program in java that will do the following:
Write a complete program in java that will do the following:Sports:             Baseball, Basketball, Football, Hockey, Volleyball, WaterpoloPlayers:           9, 5, 11, 6, 6, 7Store the data in appropriate arraysProvide an output of sports and player numbers. See below:Baseball          9 players.Basketball       5 players.Football           11 players.Hockey            6 players.Volleyball        6 players.Waterpolo       7 players.Use Scanner to provide the number of friends you have for a team sport.Provide an output of suggested sports for your group of friends. If your...
Write a complete and syntactically correct Python program to solve the following problem: You are the...
Write a complete and syntactically correct Python program to solve the following problem: You are the payroll manager for SoftwarePirates Inc. You have been charged with writing a package that calculates the monthly paycheck for the salespeople. Salespeople at SoftwarePirates get paid a base salary of $2000 per month. Beyond the base salary, each salesperson earns commission on the following scale: Sales Commission Rate Bonus <$10000 0% 0 $10000 – $100,000 2% 0 $100,001 - $500,000 15% $1000 $500,001 -...
Write a Java program that will use a two-dimensional array and modularity to solve the following...
Write a Java program that will use a two-dimensional array and modularity to solve the following tasks: Create a method to fill the 2-dimensional array with (random numbers, range 0 - 30). The array has rows (ROW) and columns (COL), where ROW and COL are class constants. Create a method to print the array. Create a method to find the largest element in the array Create a method to find the smallest element in the array Create a method to...
Write a Java program that will use a two-dimensional array and modularity to solve the following...
Write a Java program that will use a two-dimensional array and modularity to solve the following tasks: 1. Create a method to generate a 2-dimensional array (random numbers, range 0 - 500). The array has ROW rows and COL columns, where ROW and COL are class constants. 2. Create a method to print the array. 3. Create a method to find the largest element in the array 4. Create a method to find the smallest element in the array 5....
Write a Java program that will use a two-dimensional array and modularity to solve the following...
Write a Java program that will use a two-dimensional array and modularity to solve the following tasks: Create a method to generate a 2-dimensional array (random numbers, range 0 - 500). The array has ROW rows and COL columns, where ROW and COL are class constants. Create a method to print the array. Create a method to find the largest element in the array Create a method to find the smallest element in the array Create a method to find...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT