Input an int greater than 0 and print every multiple of 5 between it and 0 inclusive in descending order. If the number is not greater than 0 print "error". Print all numbers on one line with single spaces in between.
Example:
Enter a positive integer:
42
40 35 30 25 20 15 10 5 0

Respuesta :

import java.util.Scanner;

public class JavaApplication42 {

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Enter a positive integer:");

       int num = scan.nextInt();

       if (num < 0){

           System.out.println("error");

       }

       else{

           while(num >=0){

               if (num %5 == 0){

                   System.out.print(num+" ");

               }

               num--;

           }

       }

   }

I hope this helps!

The program is an illustration of loops.

Loops are used to carry out repetition operations;

The program in Python, where comments are used to explain each line is as follows:

#This gets a positive integer from the user

num = int(input("Enter a positive integer: "))

#If the input is not greater than 0

if num <= 0:

   #This prints Error

   print("Error")

#If otherwise

else:

   #This iteration is repeated until 0 is printed

   while num>=0:

       #If the current number is a multiple of 5

       if num%5 == 0:

           #The number is printed

           print(num,end=" ")

       #This decreases the number by 1, until it gets to 0

       num-=1

The above program is implemented using a while loop

Read more about similar programs at:

https://brainly.com/question/20349503