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]
1 year 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]1 year 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
The results of the spec cpu2006 bzip2 benchmark running on an amd barcelona has an instruction count of 2.389e12, an execution t
saw5 [17]

Answer:

CPI = 0.94

Explanation:

The formula for execution time is given below:

Execution time = clock cycles * cycle time

As Execution time = 750 s

clock cycle time = 0.333 ns = 0.333 * 10^-9

so putting these values in the above formula, we get

750 = clock cycles * ( 0.333 * 10^-9 )

clock cycles = 750 / ( 0.333 * 10^-9 )

clock cycles = 2.25 * 10^12

As the results of the spec cpu2006 bzip2 benchmark running on an amd barcelona has an instruction count = 2.389 * 10^12

and the formula for clock cycles is:

clock cycles = number of instructions * CPI

CPI = clock cycles / number of instructions

CPI = 2.25 * 10^12 / 2.389 * 10^12

CPI = 0.94

5 0
1 year ago
2 Name the package that contains scanner class?​
Marat540 [252]
the answer is Java.util.scanner
5 0
1 year ago
An array of ints, arr, has been declared and initialized. Write the statements needed to reverse the elements in the array. So,
Yuki888 [10]

Answer:

The sample output is below.

The code is attached.

Explanation:

Sample Output:

Original array is: 1 2 457 4 Reversed array is: 4754 2 1

Code to copy:

import java.io.*;

class Main

{

    /*Define the function revArray passing the array

      and its indices.*/

    static void revArray(int arr[], int start, int end)

    {

         /*Declare an integer variable to store the

           first index.*/

         int temp;

         //Check if array is empty.

         if (start >= end)

             return;

         //Store the first index value.

         temp = arr[start];

         //Swap the last index to first index.

         arr[start] = arr[end];

         //Store the temp value to last index.

         arr[end] = temp;

         /*Call the function recursively to swap

           rest of the values.*/

         revArray(arr, start+1, end-1);

    }  

    public static void main (String[] args)

    {

         //Declare and initialize array.

         int[] arr = {1,2,4,5,7,4};

         /*Declare an integer variable to store the

         * length of array.

         */

         int count=0;

         //Set the length of array to count.

         for(int i=0;i<arr.length;i++)

             count++;

         System.out.println("Original array is:");

         ///Print the original array.

         for(int i=0; i<count;i++)

         {

             System.out.print(arr[i]+" ");

         }  

         /*Call the function to reverse the values in

         * the array itself.

         */

         revArray(arr, 0, count-1);

         System.out.println("\nReversed array is:");

         ///Print the reversed array.

         for(int i=0; i<count;i++)

         {

             System.out.print(arr[i]+" ");

         }  

    }

}

5 0
2 years ago
Dante wants to calculate the currently monthly subtotals for the sales of golf balls in his store. Which of the following will h
cupoosta [38]
I believe the answer is B
3 0
2 years ago
The base class Pet has private fields petName, and petAge. The derived class Dog extends the Pet class and includes a private fi
Lapatulllka [165]

Answer:

Hello attached is the Java program written to solve the problem

The Pet.java and Dog.java files are unaltered

Explanation:

The input and output  codes are attached as well i.e the second image is the input while the third image is the output code

5 0
1 year ago
Other questions:
  • Write a copy constructor for carcounter that assigns origcarcounter.carcount to the constructed object's carcount. sample output
    15·2 answers
  • 8. In time series, which of the following cannot be predicted? A) large increases in demand B) technological trends C) seasonal
    11·1 answer
  • Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user shoul
    13·1 answer
  • You are given two int variables j and k, an int array zipcodeList that has been declared and initialized, an int variable nZips
    10·2 answers
  • __________ access control is a form of __________ access control in which users are assigned a matrix of authorizations for part
    8·1 answer
  • Design and document an IP addressing scheme to meet ElectroMyCycle’s needs. Specify which IP address blocks will be assigned to
    11·1 answer
  • Jen is trying to discover if a motor has failed windings. What sort of test can she do.
    6·1 answer
  • Create two classes. The first, named Sale, holds data for a sales transaction. Its private data members include the day of the m
    8·1 answer
  • Complete this truth Table. Write a program that you can enter from the keyboard, a 1 or 0 into three Boolean variables, A,B,C. W
    14·1 answer
  • Import simplegui
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!