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
kotegsom [21]
2 years ago
8

Write a recursive function num_eights that takes a positive integer pos and returns the number of times the digit 8 appears in p

os
Computers and Technology
1 answer:
nata0808 [166]2 years ago
7 0

Answer:

Explanation:

The following is written in Java. It creates the function num_eights and uses recursion to check how many times the digit 8 appears in the number passed as an argument. A test case has been created in the main method and the output can be seen in the image below highlighted in red.

  public static int num_eights(int pos){

       if (pos == 0)

           return 0;

       if (pos % 10 == 8)

           return 1 + num_eights(pos / 10);

       else

           return num_eights(pos / 10);

   }

You might be interested in
1. A device that can be used to insert data into a computer or other computational devices is
Pie

Answer:

Examples of input devices include keyboards, mouse, scanners, digital cameras, joysticks, and microphones.

Explanation:An input device is a piece of computer hardware equipment used to provide data and control signals to an information processing system such as a computer or information appliance.

7 0
3 years ago
Read 2 more answers
Which role involves designing and creating advertisements for marketing purposes?
satela [25.4K]

advertising designers

5 0
3 years ago
A blank operates as a standalone device and is shared by multiple users
Sedbober [7]
B.s. Hugh gingham thigh hangman
8 0
3 years ago
Read 2 more answers
Can someone please give me the 3.6 code practice answer I will mark you brainlyist
Stolb23 [73]

3.6 Code Practice Question:

Write a program to input 6 numbers. After each number is input, print the biggest of the number entered so far:

Answer:

nums = []

biggest = 0

for i in range(6):

    num = int(input("Number: "))

    nums.append(num)

    if(i == 0):

         print("Largest: "+str(nums[0]))

         biggest = nums[0]

    else:

         if nums[i]>biggest:

              print("Largest: "+str(nums[i]))

              biggest = nums[i]

         else:

              print("Largest: "+str(biggest))

                       

Explanation:

This question is answered using python

This line declares an empty list

nums = []

This line initalizes the biggest input to 0

biggest = 0

This iteration is perfoemed for 6 inputs

for i in range(6):

This prompts user for input

    num = int(input("Number: "))

This appends user input to the list created

    nums.append(num)

For the first input, the program prints the first input as the largest. This is implemented in the following if condition

<em>     if(i == 0):</em>

<em>          print("Largest: "+str(nums[0]))</em>

<em>          biggest = nums[0]</em>

For subsequent inputs

    else:

This checks for the largest input and prints the largest input so far

<em>          if nums[i]>biggest:</em>

<em>               print("Largest: "+str(nums[i]))</em>

<em>               biggest = nums[i]</em>

<em>          else:</em>

<em>               print("Largest: "+str(biggest))</em>

<em />

3 0
2 years ago
Using complete sentences post a detailed response to the following.
KatRina [158]

Answer:A couple disadvantaged are the migraines that is can cause. And it can cause eye strain there are alot of things that could hurt your eyes. Like being in virtual reality for to long. It can very rarely make you go blind.

Explanation: sorry if its wrong

8 0
3 years ago
Other questions:
  • ________ returns the last character in a StringBuilder variable named strBuf? Select one: A. strBuf.charAt(strBuf.length() - 1)
    15·1 answer
  • How does technology helps save the environment?​
    6·1 answer
  • Which of the following does not use a Graphic User Interface?
    14·1 answer
  • Two-dimensional random walk (20 points). A two-dimensional random walk simulates the behavior of a particle moving in a grid of
    14·1 answer
  • PLZ help
    5·1 answer
  • How do you close a file?
    12·2 answers
  • Hi, please help me complete my Database Development 2 hw by completing what should been done from the document and show the code
    11·1 answer
  • How would you design an adaptive environment for people who are blind?
    10·1 answer
  • Amogus :0) owo have a good day y'all
    12·1 answer
  • In a selection, the else clause executes ______________. a. always b. when the tested condition is false c. when the tested cond
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!