1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kompoz [17]
3 years ago
13

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 g

reater 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
Computers and Technology
1 answer:
Alexus [3.1K]3 years ago
8 0

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!

You might be interested in
Is it better to try to prevent damage from natural disasters or to deal with disasters after they occur?
Hatshy [7]

Answer:

It is better to prevent damage from a natural disaster. It dosen't matter if we deal with it after it occurs, because it has already destroyed things and you can't fix destroyed natural things

Explanation:

4 0
3 years ago
Read 2 more answers
What is your favorite anime ( All movies and episodes related to them count )
Citrus2011 [14]

Answer:

B. Naruto

Explanation:

7 0
3 years ago
Read 2 more answers
Use the following cell phone airport data speeds​ (Mbps) from a particular network. Find P10. 0.1 0.1 0.3 0.3 0.3 0.4 0.4 0.4 0.
sasho [114]

Answer:

P_{10} =0.1

Explanation:

Given

0.1, 0.1, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.6, 0.7, 0.7, 0.7, 0.8, 0.8

Required

Determine P_{10}

P_{10} implies 10th percentile and this is calculated as thus

P_{10} = \frac{10(n+1)}{100}

Where n is the number of data; n = 14

P_{10} = \frac{10(n+1)}{100}

Substitute 14 for n

P_{10} = \frac{10(14+1)}{100}

P_{10} = \frac{10(15)}{100}

Open the bracket

P_{10} = \frac{10 * 15}{100}

P_{10} = \frac{150}{100}

P_{10} = 1.5th\ item

This means that the 1.5th item is P_{10}

And this falls between the 1st and 2nd item and is calculated as thus;

P_{10} = 1.5th\ item

Express 1.5 as 1 + 0.5

P_{10} = (1 +0.5)\ th\ item

P_{10} = 1^{st}\ item +0.5(2^{nd} - 1^{st}) item

From the given data; 1st\ item = 0.1 and 2nd\ item = 0.1

P_{10} = 1^{st}\ item +0.5(2^{nd} - 1^{st}) item becomes

P_{10} =0.1 +0.5(0.1 - 0.1)

P_{10} =0.1 +0.5(0)

P_{10} =0.1 +0

P_{10} =0.1

3 0
3 years ago
Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar co
aleksklad [387]

Answer:

public static double drivingCost(int drivenMiles, double milesPerGallon,double dollarsPerGallon){

       return (drivenMiles/milesPerGallon)*(dollarsPerGallon);

   }

Find a complete java program that prompts the user to enter this values and the calls this Method in the explanation section.

Explanation:

<em>import java.util.Scanner;</em>

<em>public class ANot {</em>

<em>    public static void main(String[] args) {</em>

<em>    Scanner in = new Scanner(System.in);</em>

<em>        System.out.println("Please Enter the Driven Miles");</em>

<em>        int drivenMiles = in.nextInt();</em>

<em />

<em>        System.out.println("Please Enter the Your fuel consumption in miles/gallon");</em>

<em>        double milesPerGallon = in.nextDouble();</em>

<em />

<em>        System.out.println("Please Enter the cost of fuel in Dollars/gallon");</em>

<em>        double dollarsPerGallon = in.nextDouble();</em>

<em />

<em>        double dollarCost = drivingCost(drivenMiles,milesPerGallon,dollarsPerGallon);</em>

<em>        System.out.println("The Total Cost in Dollars is "+dollarCost);</em>

<em>        }</em>

<em>    public static double drivingCost(int drivenMiles, double milesPerGallon,double dollarsPerGallon){</em>

<em />

<em>        return (drivenMiles/milesPerGallon)*(dollarsPerGallon);</em>

<em>    }</em>

<em>}</em>

8 0
3 years ago
Write only in C, not C++.
yawa3891 [41]

Answer:

#include <iostream>

using namespace std;

int main() {

  int k;

double d;

string s;

cin >> k >> d >> s;

cout << s << " " << d << " " << k << "\n" << k << " " << d << " " << s; }

                                                                   

Explanation:

k is int type variable that stores integer values.

d is double type variable that stores real number.

s is string type variable that stores word.

cin statement is used to take input from user. cin takes an integer, a real number and a word from user. The user first enters an integer value, then a real number and then a small word as input.

cout statement is used to display the output on the screen. cout displays the value of k, d and s which entered by user.

First the values of k, d and s are displayed in reverse order. This means the word is displayed first, then the real number and then the integer separated again by EXACTLY one space from each other. " " used to represent a single space.

Then next line \n is used to produce a new line.

So in the next line values of k, d and s are displayed in original order (the integer , the real, and the word), separated again by EXACTLY one space from each other.

The program along with the output is attached.

7 0
4 years ago
Other questions:
  • OSHA requires that employers pay for most required personal protective equipment (PPE), including: A. Hard hats B. Logging boots
    5·1 answer
  • Your dad just purchased a new desktop with Windows 8 Professional. He is calling you, informing you that he is unable to remote
    9·1 answer
  • Mass production usually uses an _______________ ____________ or production line technique.
    7·1 answer
  • "The pkill command terminates _________."
    14·1 answer
  • Which group on the sparkline tools design tab would you choose if you wanted to change the data source of the sparkline? (1 poin
    10·1 answer
  • What is the internet?
    5·2 answers
  • Using the media as equipment for living. Explain how you would use some form of media to serve a purpose in your life—and what t
    6·2 answers
  • why is there a need of properly interpreting teacher's/manufacturer's specifications before operating any food processing equipm
    9·1 answer
  • Qr code is more developed than barcode​
    11·1 answer
  • The purpose of Appetizers on the menu​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!