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
Arte-miy333 [17]
2 years ago
3

Add an if branch to complete double_pennies()'s base case. Sample output with inputs: 1 10 Number of pennies after 10 days: 1024

Note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message.

Computers and Technology
1 answer:
Lerok [7]2 years ago
5 0

Explanation:

A recursive function double_pennies is created which takes two inputs, the amount of pennies and the number of days.

The base case is

if days == 0:

       return pennies

otherwise function keeps on calling itself until

total = double_pennies((pennies * 2), (days - 1));

Python Code:

def double_pennies(pennies, days):

   total = 0

   if days == 0:

       return pennies

   else:

       total = double_pennies((pennies * 2), (days - 1));

   return total

Driver Code:

pennies = 1

days = 10

print("no. of pennies after", days, "days: ", end="")

print(double_pennies(pennies, days))

Output:

no. of pennies after 10 days: 1024

no. of pennies after 20 days: 1048576

You might be interested in
Chinh wants to have a program print, "Sorry, but that isn’t one of your options" until the user enters the correct information.
kolbaska11 [484]

Answer:

a wile loop

Explanation:

8 0
2 years ago
Which code fragment would correctly identify the number of arguments passed via the command line to a Java application, excludin
blondinia [14]

Answer:

The answer is a. int count =args.length

Explanation:

Which code fragment would correctly identify the number of arguments passed via the command line to a Java application, excluding the name of the class that is being invoked?

a. int count = args.length;

b. int count=0; while (!(args[count].equals(""))) count ++;

c. int count = args.length - 1;

d. int count = 0; while (args[count] != null) count ++;

The answer is a. int count =args.length

args is a string array object, which contains set of all arguments. You can find the number of argument by using args.length.

8 0
2 years ago
Kylee needs to ensure that if a particular client sends her an email while she is on vacation, the email is forwarded to a
Ne4ueva [31]

Kylee needs to ensure that if a particular client sends her an email while she is on vacation, the email is forwarded to a  coworker for immediate handling. Therefore, she should let her coworker into her email, so they can recieve the messages.

6 0
2 years ago
Edhesive: Assignment 4: Evens and Odds
solniwko [45]

Answer:

Written in Python

n = int(input("How many numbers do you need to check? "))

odd = 0

even = 0

for i in range(1,n+1):

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

     if num%2 == 0:

           print(str(num)+" is an even number")

           even = even + 1

     else:

           print(str(num)+" is an odd number")

           odd = odd + 1  

print("You entered "+str(even)+" even number(s).")

print("You entered "+str(odd)+" odd number(s).")

Explanation:

<em>I've added the full source code as an attachment where I use comments (#) as explanation</em>

Download txt
6 0
2 years ago
Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burn
gayaneshka [121]

Answer:

#include <iostream>

# include <conio.h>

using namespace std;

float fat_burning_heart_rate(float age);

main()

{

float age,bpm;

cout<<"enter the age of the person"<<endl;

cin>>age;

if (age>=18 && age<=75)

{

bpm=fat_burning_heart_rate(age);

cout<<"fat burning heart rate for the age of"<<age<<"="<<bpm;

}

else

cout<<"Invalid age";

getch();

}

float fat_burning_heart_rate(float age)

{

 

float a;

 

a= (220-age)*0.7;

return a;

}

Explanation:

In this program, the variable named as age has been taken to enter the age of the person, needs to calculate the burning heart rate. All the variables taken in float, as the age and fat burning heart rate should come in decimal value.

The formula has been used as mention in question that,

a= (220-age)*0.7;

8 0
2 years ago
Other questions:
  • Into which of these files would you paste copied information to create an integrated document?
    13·2 answers
  • A workgroup database is a(n) _____ database
    9·1 answer
  • which of these paste options is commonly available from the paste options button? A&gt; use the destination them. B. keep the em
    14·2 answers
  • While researching ideas for cutting energy costs is his company. Hector watches an online video in which a business expert says,
    6·2 answers
  • What is the Gain (dB) of a transmission if the Maximum Data Rate is 1 Gbps and the Bandwidth =7000 MHz? Group of answer choices
    6·1 answer
  • As part of the duties of a digital forensics examiner, creating an investigation plan is a standard practice. Write a 3 to 4 (no
    9·1 answer
  • Python
    9·1 answer
  • PLEASE AWNSER 50 POINTS PLUS BRAINLEST ILL FAIL MY GRADE IF I DONT AWNSER IN A HOUR!
    15·1 answer
  • Lian is asked to create a variable that will keep track of how many times the user has tried to enter their password. What kind
    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
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!