answer.
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
juin [17]
2 years ago
15

Write a program that takes a single integer input from the user and stores it in a variable. Your program should increase the va

lue of this variable by one three times, printing "number is now " followed by its value each time, then decrease it by one three times, again printing "number is now " and the value each time
Computers and Technology
1 answer:
Allushta [10]2 years ago
8 0

Answer:

Question is answered using python:

num = int(input("User Input: "))

for i in range(3):

    num = num+1

    print("Number is now "+str(num))

for i in range(3):

    num = num-1

    print("Number is now "+str(num))

Explanation:

This line prompts user for input

num = int(input("User Input: "))

The following iterates from 1 to 3

for i in range(3):

This increments user input each time

    num = num+1

This prints the value of num after increment

    print("Number is now "+str(num))

The following iterates from 1 to 3

for i in range(3):

This decrements the value of num

    num = num-1

This prints the value of num after decrement

    print("Number is now "+str(num))

You might be interested in
Write a second constructor as indicated. Sample output: User1: Minutes: 0, Messages: 0 User2: Minutes: 1000, Messages: 5000
Mashcka [7]

Complete Question:

Write a second constructor as indicated. Sample output:User1: Minutes: 0, Messages: 0User2: Minutes: 1000, Messages: 5000// ===== Code from file PhonePlan.java =====public class PhonePlan { private int freeMinutes; private int freeMessages; public PhonePlan() { freeMinutes = 0; freeMessages = 0; } // FIXME: Create a second constructor with numMinutes and numMessages parameters. /* Your solution goes here */ public void print() { System.out.println("Minutes: " + freeMinutes + ", Messages: " + freeMessages); return; }}

Answer:

The second constructor is given as:

//This defines the constructor, the name has to be the same as the class //name

PhonePlan(int numOfMinutes, int numberOfMessages) {

this.freeMinutes = numOfMinutes;

this.freeMessages = numberOfMessages

}

Explanation:

The second constructor is defined using java programming language.

  1. The given class has two constructors This is called "Constructor Overloading) which implements polymophism
  2. In the second constructor that we created, we pass in two arguments of type integer numOfMinutes and numberOfMessages.
  3. In the constructor's body we assign these values to the initially declared variables freeMinutes and freeMessages
6 0
2 years ago
g Fill the validateForm function to check that the phone number is 10 characters long and that the user name is less than 11 cha
Rom4ik [11]

Answer:

function validateForm(event)

{

event.preventDefault();

var phoneNumber = form.phoneNumber.value;

var userName = form.userName.value;

if(phoneNumber.length!=10)

console.log("Phone Number is Invalid");

if(userName.length<11)

console.log("User Name is Invalid"); }

8 0
2 years ago
Write the prototype for a function named showValues. It should accept an array of integers and an integer for the array size as
aalyn [17]

Answer:

void showValues(int [<em>maximum</em><em> </em><em>volume</em>],int);

4 0
2 years ago
Read 3 more answers
Given six memory partitions of 300 KB, 600 KB, 350 KB, 200 KB, 750 KB, and 125 KB (in order), how would the first-fit, best-fit,
Inga [223]

Answer:

In terms of efficient use of memory: Best-fit is the best (it still have a free memory space of 777KB and all process is completely assigned) followed by First-fit (which have free space of 777KB but available in smaller partition) and then worst-fit (which have free space of 1152KB but a process cannot be assigned). See the detail in the explanation section.

Explanation:

We have six free memory partition: 300KB (F1), 600KB (F2), 350KB (F3), 200KB (F4), 750KB (F5) and 125KB (F6) (in order).

Using First-fit

First-fit means you assign the first available memory that can fit a process to it.

  • 115KB will fit into the first partition. So, F1 will have a remaining free space of 185KB (300 - 115).
  • 500KB will fit into the second partition. So, F2 will have a remaining free space of  100KB (600 - 500)
  • 358KB will fit into the fifth partition. So, F5 will have a remaining free space of 392KB (750 - 358)
  • 200KB will fit into the third partition. So, F3 will have a remaining free space of 150KB (350 -200)
  • 375KB will fit into the remaining partition of F5. So, F5 will a remaining free space of 17KB (392 - 375)

Using Best-fit

Best-fit means you assign the best memory available that can fit a process to the process.

  • 115KB will best fit into the last partition (F6). So, F6 will now have a free remaining space of 10KB (125 - 115)
  • 500KB will best fit into second partition. So, F2 will now have a free remaining space of 100KB (600 - 500)
  • 358KB will best fit into the fifth partition. So, F5 will now have a free remaining space of 392KB (750 - 358)
  • 200KB will best fit into the fourth partition and it will occupy the entire space with no remaining space (200 - 200 = 0)
  • 375KB will best fit into the remaining space of the fifth partition. So, F5 will now have a free space of 17KB (392 - 375)

Using Worst-fit

Worst-fit means that you assign the largest available memory space to a process.

  • 115KB will be fitted into the fifth partition. So, F5 will now have a free remaining space of 635KB (750 - 115)
  • 500KB will be fitted also into the remaining space of the fifth partition. So, F5 will now have a free remaining space of 135KB (635 - 500)
  • 358KB will be fitted into the second partition. So, F2 will now have a free remaining space of 242KB (600 - 358)
  • 200KB will be fitted into the third partition. So, F3 will now have a free remaining space of 150KB (350 - 200)
  • 375KB will not be assigned to any available memory space because none of the available space can contain the 375KB process.
8 0
2 years ago
Which option describes how to apply a left indent to a selected paragraph?
Leni [432]

Answer:

All the above options are correct.

Explanation:

In a Microsoft Word, to apply a left indent to a selected paragraph, a user can do any of the following:

1. Use the combination keys Ctrl+M on the keyboard to insert a left indent.

2. Use the mouse to pull the left indent marker on the ruler to create a left indent.

3. Another option is to go to the Paragraph dialogue box, place a positive value in the box labeled Left.

Hence, in this case, the correct answer is that: All the above options are correct.

8 0
1 year ago
Read 2 more answers
Other questions:
  • Your computer is crashing on a regular basis. Which of the following is an operation available to the user that should help rese
    14·2 answers
  • While creating an animation, Gina has prepared a document stating the purpose and type of audience for the animation. What has
    6·1 answer
  • 10. (P37) Compare GBN, SR, and TCP (no delayed ACK). Assume that the timeout values for all three protocols are sufficiently lon
    12·1 answer
  • Write a program that has the following String variables: firstName, middleName, and lastName. Initialize these with your first,
    7·1 answer
  • Exercise 4: Bring in program grades.cpp and grades.txt from the Lab 10 folder. Fill in the code in bold so that the data is prop
    12·1 answer
  • The geographic coordinate system is used to represent any location on Earth as a combination of latitude and longitude values. T
    5·1 answer
  • Which of these are characteristics of a Python data type? Check all that apply.
    11·1 answer
  • Quantum units of information deploy the properties of entanglement and ____ to offer exponentially greater computing power.
    9·1 answer
  • A small e-commerce company uses a series of Robotic Process Automation solutions to manage the backup of data from individual wo
    9·1 answer
  • A data scientist is writing a Machine Learning (ML) algorithm using a large data set.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!