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
Musya8 [376]
2 years ago
10

Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 5 as long as the

value is less than or equal to the second integer. Ex: If the input is: "-15" 10 the output is: "-15" "-10" "-5" 0 5 10 Ex: If the second integer is less than the first as in: 20 5 the output is: Second integer can't be less than the first.
Computers and Technology
1 answer:
Anna11 [10]2 years ago
6 0

Answer:

The program in Python is as follows:

num1 = int(input())

num2 = int(input())

if num2 < num1:

   print("Second integer can't be less than the first.")

else:

   for i in range(num1,num2+1,5):

       print(i,end=" ")

Explanation:

This gets the first integer from the user

num1 = int(input())

This gets the second integer from the user

num2 = int(input())

If the second is less than the first, the following prompt is printed

<em>if num2 < num1:</em>

<em>    print("Second integer can't be less than the first.")</em>

If otherwise, the number between the intervals is printed with an increment of 5

<em>else:</em>

<em>    for i in range(num1,num2+1,5):</em>

<em>        print(i,end=" ")</em>

<em />

You might be interested in
Just a quick question, how do you set something == to char and int in an if statement (java)
Troyanec [42]

This is the requested code in java.

public class <em>CharTest</em> {

   public static String checkCharacter(String text, int index) {

       if (0 <= index && index <= text.length()) {

           char ch = text.charAt(index);

           if (Character.isLetter(ch)) {

               return ch + " is a letter";

           } else if (Character.isDigit(ch)) {

               return ch + " is a digit";

           } else if (Character.isWhitespace(ch)) {

               return ch + " is a whitespace character";

           } else {

               return ch + " is an unknown type of character";

           }

       } else {

           return "index " + index.toString() + " is out of range";

       } // <em>end if</em>

   } // <em>end function checkChar()</em>

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

       // <em>Test the three samples from the specification.</em>

       System.out.println(<em>checkCharacter</em>("happy birthday", 2));

       System.out.println(<em>checkCharacter</em>("happy birthday", 5));

       System.out.println(<em>checkCharacter</em>("happy birthday 2 you", 15));

   } // <em>end function main()</em>

} // <em>end class CharTest</em>

The function <em>checkcharacter</em>(text, index) returns a string value describing the kind of character found at the position in text specified by index; whether it was a letter, digit, whitespace, or an unknown kind of character.

How it does that is to make use of respective functions defined within the Character class in java. That is

  • isLetter(char) returns a bool specifying if the char parameter is a letter.
  • isDigit(char) returns a bool specifying if the char parameter is a digit.
  • isWhitespace(char) returns a bool specifying if the char parameter is a whitespace character.

It calls these functions in an if statement. These else part of the if statement is then executed if the character is neither a <em>letter</em>, <em>digit</em>, or <em>whitespace</em>.

Finally, the function main() calls <em>checkCharacter</em>() three times to test the function and return the results to the console.

Another example of a java program on characters is found in the link below

brainly.com/question/15061607

3 0
2 years ago
¿como la imagen organiza la realidad?
Troyanec [42]

Answer:

Las imágenes son las percepciones visuales que las personas tienen respecto de la realidad que los rodea. Así, a través de la visión, las personas pueden interpretar el contexto en el cual se encuentran inmersos, organizando los distintos componentes de la realidad en la cual desarrollan sus vidas, para poder comprender entonces de qué modo proceder ante las diferentes eventualidades de la vida.

Es decir que, a través de las imágenes, y en conjunto con las demás percepciones sensoriales, los seres humanos pueden contextualizarse en un entorno en el cual se desenvuelven, organizando su vida y su realidad a futuro.

7 0
2 years ago
In this lab, 172.30.0.0 represents the __________ network and 10.20.1.0 represents the _________ network.
umka21 [38]
172.30.0.0: private network
10.20.1.0: public network
6 0
3 years ago
How to make an upside down exclamation point on mac?
denis-greek [22]
Option + 1

-----------------------------
5 0
3 years ago
Create a class Car, which contains Three data members i.e. carName (of string type), ignition (of bool type), and currentSpeed (
olasank [31]

Answer:

Copy paste it.

Explanation:

#include <iostream>

#include <string>

using namespace std;

//Create a class Car, which contains • Three data members i.e. carName (of string type), ignition (of bool type), and //currentSpeed (of integer type)

class Car

{

public:

string carName;

bool ignition;

int currentSpeed;

//A no-argument constructor to initialize all data members with default values

//default value of string is "",bool is false,int is 0

Car()

{

carName="";

ignition=false;

currentSpeed=0;

}

//A parameterized constructor to initialize all data members with user-defined values

Car(string name,bool i,int speed)

{

carName=name;

ignition=i;

currentSpeed=speed;

}

//Three setter functions to set values for all data members individually

// Three getter function to get value of all data members individually

void setCarName(string s)

{

carName=s;

}

void setIgnition(bool ig)

{

ignition=ig;

}

void setCurrentSpeed(int speed)

{

currentSpeed=speed;

}

string getCarName()

{

return carName;

}

bool getIgnition()

{

return ignition;

}

int getCurrentSpeed()

{

return currentSpeed;

}

//A member function setSpeed( ) // takes integer argument for setting speed

void setSpeed(int sp1)

{

currentSpeed=sp1;

}

};

//Derive a class named Convertible

class Convertible:public Car

{

//A data member top (of Boolean type)

public:

bool top;

public:

//A no-argument constructor to assign default value as “false” to top

Convertible()

{

top=false;

}

//A four argument constructor to assign values to all data-members i.e. carName, ignition,

//currentSpeed and top.

Convertible(string n,bool i,int s,bool t):Car(n,i,s)

{

carName=n;

ignition=i;

currentSpeed=s;

top=t;

}

// A setter to set the top data member up

void setTop(bool t)

{

top=t;

}

//A function named show() that displays all data member values of invoking object

void show()

{

cout<<"Car name is:"<<carName<<endl;

cout<<"Ignition is: "<<ignition<<endl;

cout<<"Current Speed is :"<<currentSpeed<<endl;

cout<<"Top is:"<<top<<endl;

}

};

//main function

int main()

{

//creating object for Convertible class

Convertible c1("Audi",true,100,true);

c1.show();

c1.setCarName("Benz");

c1.setIgnition(true);

c1.setCurrentSpeed(80);

c1.setTop(true);

c1.show();

cout<<"Car Name is: "<<c1.getCarName()<<endl;

cout<<"Ignition is:"<<c1.getIgnition()<<endl;

cout<<"Current Speed is:"<<c1.getCurrentSpeed()<<endl;

return 0;

}

4 0
3 years ago
Other questions:
  • Fred opens a web browser and connects to the www.certskills.com website. Which of the following are typically true about what ha
    10·1 answer
  • A Web ____ is a software program that retrieves the page and displays it. Select one:
    5·1 answer
  • A company has its branches spread over five places in a state. It has become difficult for employees to transfer information and
    7·1 answer
  • On most desktop computers, most of the USB ports are on the back of the computer case. Generally, you'll want to connect your mo
    13·1 answer
  • Which type of server runs Active Directory?
    12·1 answer
  • Read the section, "Junior Year." Why would someone chose to complete an apprenticeship after high school? How many occupations c
    14·2 answers
  • The minimum spanning tree of an undirected graph G exists if and only if G is connected. True or False?
    12·1 answer
  • What is it called when there are an equal number of characters on either side of the horizontal center of the page?
    8·1 answer
  • URGENT!!!
    9·1 answer
  • What are the 3 rules of music<br><br> ps: there is no music subject so i had to put something else
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!