For this exercise, you are going to write a recursive function that counts down to a Blastoff!
Your recursive function will not actually print. It will return a String that can be printed from the main function. Each recursive call will add on to that string.
In your main function, prompt the user for a starting value, then print the results.
Sample Output
Please enter a number to start:
5
5 4 3 2 1 Blastoff!
import java.util.Scanner;
public class Countdown
{
public static void main(String[] args)
{
// Start here
}
public static String countdown(int number)
{
// Base case - return Blastoff!
// Recursive call
}
}

Answers

Answer 1

Answer:

import java.util.Scanner;

public class Countdown {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

int n;

System.out.print("Please enter a number to start: ");

n = input.nextInt();

System.out.print(countdown(n));

}

public static String countdown(int number) {

if(number>0) {     return " "+number+countdown(number-1);    }

   else    {        return " Blastoff!";    }

}

}

Explanation:

The main method begins here

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

This declares an integer variable n

int n;

This prompts user for a number

System.out.print("Please enter a number to start: ");

This gets user input n

n = input.nextInt();

This calls the countdown function

System.out.print(countdown(n));

}

The countdown function begins here

public static String countdown(int number) {

This is the base case where input number is greater than 0

if(number>0) {     return " "+number+countdown(number-1);    }

This ends the recursion

   else    {        return " Blastoff!";    }

}


Related Questions

g Create a Java program that takes input of a list of integers from the user, stores them into an array and then finally uses the array contents to output the list of integers in reverse. The user's input begins with the number of integers to be stored in the array. For coding simplicity, follow each output integer by a space, including the last one. Assume that the list will always contain fewer than 20 integers.Create a Java program Ex: If the input is: 8 5 2 3 4 10 6 8 9

Answers

Answer:

import java.util.Scanner;

public class Main{

public static void main(String[] args) {

int arraylent;

Scanner input = new Scanner(System.in);

System.out.print("Array Length: ");

 arraylent= input.nextInt();

int[] myarray = new int[arraylent];

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

    myarray[i] = input.nextInt();

for(int i = arraylent-1; i>=0;i--)

System.out.println(myarray[i]);

}

}

Explanation:

This declares the length of the array

int arraylent;

This next two lines prompt and get the array length i.e. number of input

System.out.print("Array Length: ");

 arraylent= input.nextInt();

This declares the array as type integer. And the length of the array is gotten from the user input

int[] myarray = new int[arraylent];

This gets the items of the array

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

    myarray[i] = input.nextInt();

This reverse and prints the array

for(int i = arraylent-1; i>=0;i--)

System.out.println(myarray[i]);

Why do people want phones so bad??

Answers

To help explain this, take a look at these reasons why kids should have cell phones:

#1 To keep in touch. What happens if you're running late picking your child up from school? ...

#2 To talk to friends. ...

#3 To stay safe. ...

#4 To develop essential skills. ...

#8 To improve their organization. ...

#11 To encourage responsibility.

Because we live in a world full of technology and we use it for almost everything. They made life easier in some ways

Write a program that declares three one-dimensional arraysnamed miles, gallons, and mpg. Each array should be declared in main() and should becapable of holding ten double-precision numbers. The numbers that should be stored in miles are240.5, 300, 189.6, 310.6, 280.7, 206.9, 199.4, 160.3, 177.4, and 192.3. The numbers should bestored in gallons are 10.3, 15.6, 8.7, 14, 16.3, 15.7, 14.9, 10.7, 8.3, and 8.4.

Answers

Answer:

#include <iostream>

using namespace std;

int main(){

   double miles[10] = {240.5, 300, 189.6, 310.6, 280.7, 206.9, 199.4, 160.3, 177.4, 192.3};

   double gallons[10] = {10.3, 15.6, 8.7, 14, 16.3, 15.7, 14.9, 10.7, 8.3, 8.4};

   double mpg[10];

   for (int i = 0; i < 10; i++){

       mpg[i] = miles[i]/ gallons[i];

       cout << "mpg: " << mpg[i] << endl;

   }

}

Explanation:

The C++ source code declares three arrays miles, gallons and mpg with an array length of 10. The gallons and miles arrays are assigned 10 array items each and they are used to push values to the mpg array in the for loop statement. The result of each item in the mpg array is displayed on the screen.

Which of the following apertures will give you the shallowest depth of field?
a)2.8
b)5.6
c)11
d)22
e)2
50 points and brainliest

Answers

Answer:

a.2.8

The f-stops work as inverse values, such that a small f/number (say f/2.8) corresponds to a larger or wider aperture size, which results in a shallow depth of field; conversely a large f/number (say f/16) results in a smaller or narrower aperture size and therefore a deeper depth of field.

Display filters and capture filters can be interchanged because they use the same syntax. A. True B. False

Answers

Answer:

Very True

Explanation:

User max owns a directory games, containing a text file called ourgames.txt that he shares with users belonging to the group gameplayers. Those users may read and execute this file, but not delete it. They may not add other files to the directory. Others may neither read, write, nor execute anything in games. What would be the appropriate ownerships and permissions for both directory games and the file ourgames.txt look like

Answers

Answer:

The directory games folder: drwxr-x---

ourgames.txt files : -rwxr-x---

Explanation:

The directory games and the ourgames.txt file are owned by max who has read, write and execute permissions for both, where the 'd' in the first column represents the directory. The gameplayers group has read and execute permissions represented by the 'r' and 'x' letters. The other group is the third section with just dashes which means no permission is granted for the file.

Is it important to study information systems

Answers

Answer:

There is massive importance if you want to study information study.

It can help you understand the data, organize, and process the data, using which we can generate and share information.

Explanation:

It largely depends on your interest and requirement, but a better knowledge or clue about information systems may help analyze the data especially if you want to become a data scientist, machine learning, Artificial intelligence or deep learning, etc.

It can help you understand the data, organize, and process the data, using which we can generate and share information.

A great understanding of information systems may exponentially increase the productivity, growth, performance, and profit of the company.

Most Professions get exposed to information Systems no matter what their career objective is, as it may help in having better decision making based on the information they get through data.

So, yes!

There is a massive importance if you want to study information study.

How can you get access to help? Check all that apply

Answers

Answer:

The answer is "F1"

Explanation:

Please find the complete question in the attachment file.

The F1 key is also known as the function key, which can be used to configure on a device or console key to cause such actions, a form of a soft button, to also be performed by a web browser control parser or software application. The main purpose of the F! key is to open the Help screen for all programs.

fast guys can u tell its answer
find the count of value from cells a5 through e12

Answers

Answer:

See the bottom status bar of excel, it will show the average, count and sum of values in the selection.

A value chosen by the responder to identify a unique IKE SA is a _________.
A. Initiator SPI
B. Responder SPI
C. Flag
D. Message identifier

Answers

Answer:

Responder SPI

Explanation:

Responder SPI : Cookie of an individual referring to an application from the SA organization, a message from the SA, or a delete from the SA.

Factor 72y+108z

lmk the answer asap

Answers

36(2y+3z)

This is the answer , please mark brainliest if correct.

Write a program that reads a stream of integers from a file and prints to the screen the range of integers in the file (i.e. [lowest, highest]). You should first prompt the user to provide the file name. You should then read all the integers from the file, keeping track of the lowest and highest values seen in the entire file, and only print out the range of values after the entire file has been read.

Answers

Answer:

This question is answered using C++ programming language

#include <fstream>

#include<iostream>

using namespace std;

int main() {

  string fname;

  cout<<"Enter Filename: ";

  cin>>fname;

  int lowest = 0;

int highest = 0;

  ifstream ifs(fname);

  int x;

  while (ifs >> x){

  if(x < lowest){

   lowest= x;

  }

  if(x > highest) {

   highest = x;

  }

  }

  ifs.close();    

  for(int i = lowest; i<=highest;i++)

  {

   cout<<i<<" ";

  }

     

}

Explanation:

This line declares fname as string  

string fname;

This prompts user for filename

  cout<<"Enter Filename: ";

This gets filename

  cin>>fname;

This declares and initializes lowest to 0

      int lowest = 0;

This declares and initializes highest to 0

int highest = 0;

This defines the file using ifstream

  ifstream ifs(fname+".txt");

This declares x as integer. x is used to read integers in the file

  int x;

The following iteration will be repeated until there is no other integer to be read from the file

  while (ifs >> x){

This checks for lowest

  if(x < lowest){

   lowest= x;

  }

This checks for highest

  if(x > highest) {

   highest = x;

  }

  }

This closes the file. i.e. the file has been read

  ifs.close();    

The following iteration prints the range of values from lowest to highest

  for(int i = lowest; i<=highest;i++)  {

   cout<<i<<" ";

  }  

Please note that the filename must be entered with its extension

Benjamin took a photo that focused on certain part of an image while blurring out the rest. What is this effect called?
A.
alternate focus
B.
major focus
C.
minor focus
D.
selective focus

Answers

Answer:

(D) selective focus

Explanation: hope this helps!

Answer:

D. Selective Focus

Explanation:

Photographers commonly use the tilt-shift effect to focus on a certain part of the image while blurring the rest of the photograph. They refer to this as selective focus.

If you are working on doing senior portraits and want a lens that will give you the best shallow depth of field which lens would you choose?
a) 55mm f1.2 (focal length of 55mm, maximum aperture of 1.2)
b) 28-80mm f4.5 (Zoom lens with focal length from 28-80mm, max aperture 4.5)
c) 18mm f5.6
d) 50mm f1.4
45 points and brainliest

Answers

Answer: The answer is C     Hope this helps :)    Please mark Brainliest

Explanation:

Answer:

c) 18mm f5.6

Explanation:

For the best lens that offers the best shallow depth of field, you need to choose the one with the maximum apertature but does not zoom.

Hence choice c) has the maximum aperture and does not zoom.

Hope this helps :)

Analyze the needs of the National Security team and help them articulate its problems, develop solutions to meet its needs, and deliver a recommendation that is aligned with the extant national objectives.

Answers

Answer:

Following are the solution to this question:

Explanation:

The Council's role has been to assist and support the President regarding national security and foreign policies ever since its inception under Truman. This Committee often acts as the primary arm of a President to organize these initiatives between government agencies.

The Leader holds sway over the NSC. Its Secretary Of Defense offers a range of options for the Administration on policy issues. The director of national intelligence helps prepare the administration's foreign travel, among other tasks, and offers context memos and staffing for the administration's discussions and phone interviews involving global leaders.

Safety investments were taken for many years utilizing threat cost-benefit analysis wherein the effect metric has been largely focused on even a risk reduction comparative estimate. To evaluate investment decisions, most aim to conduct similar analyses.

Even so, the potential threat is much harder to measure for high-security installations that potential hazard since the likelihood of an attack is highly uncertain and depends strongly on undefinable psychological factors like deterrence as well as the intensity of enemy goals.

What is the name of the tab that becomes available after you add and select an image in your PowerPoint presentation?
Home
Insert
Picture
View

ASAP PLS

Answers

Answer:

INSERT

Explanation:

INSERT PCIURE

what stage is the most inner part of the web architecture where data such as, customer names, address, account numbers, and credit card info is the store?

Answers

Never store the card-validation code or value (three- or four-digit number printed on the front or back of a payment card used to validate card-not-present transactions). Never store the personal identification number (PIN) or PIN Block. Be sure to mask PAN whenever it is displayed.

What does Stand for in web design

Answers

Answer:

g

Explanation:

h

A company is performing an analysis on the computers at its main office. The computers are spaced along a single row. The analysis is performed in the following way: 1. Choose a contiguous segment of a certain number of computers, starting from the beginning of the row. 2. Analyze the available hard disk space on each of the computers. 3. Determine the minimum available disk space within this segment.

Answers

Answer:

array = input("Enter the list of computer memory: ").split(',')

int_arr = [int(x) for x in array]

segment = int(input("Enter the length of segment to analyze: "))

list_len = len(int_arr)

segList = []

mini = []

for x,i in enumerate(int_arr):

   seg = int_arr[i-1:segment+i-1]

   if len(seg) == segment:

       segList.append(seg)

for x in segList:

   mini.append(min(x))

result = mini.index(min(mini))

print("Segment with the minimum memory is: ",segList[result])

Explanation:

The python program prints out the segment after analysis, with the smallest disk memory space. The code gets the array of computer rows from the user input and segments the array with the number of segment input, then the minimum is compared for all segments in the network.

Describe the general strategy behind deadlock prevention, and give an example of a practical deadlock prevention method.
Multi-programming (or multi-tasking) enables more than a single process to apparently execute simultaneously. How this can be achieved on a uni-processor?]

Answers

Answer:

In multi-programming, you use semaphore constructs to protect shared resources. Your program thread or process will block if you want to claim a semaphore when another thread or process has it claimed.

Generally you need to keep the code scope of the claimed semaphore (a.k.a. the critical section) as small as possible, and also, prevent claiming another semaphore within a given critical section.

As you draw a star, pressing the shift key while you drag increases the number of points on the star. True or false

Answers

Answer:

true

Explanation:

If I want to control the aperture and I want the camera to control the shutter speed which setting on the mode dial is most appropriate?
a)AV
b) TV
c) M
d) P
since this is my last question im giving 100 points and brainliest

Answers

Answer:

answer is a

hopes this helps

You manage a Windows server that has an attached printer that is used by the Sales department. The sales manager has asked you to restrict access to the printer as follows:Sally needs to connect to a printer, print documents, and pause and resume her own print jobs.Damien needs to pause and resume documents for all users, but does not need to change printer properties.You want to assign the most restrictive permissions that meet the sales manager's requirements. What should you do

Answers

Answer:

Damien would be assign the Manage Documents permission while Sally on the other hand will be assign the permission to print.

Explanation:

Based on the information given in order for me to assign a restrictive permission that will meet the requirements of the sale manager's what I will do is for me to assign the Manage Documents permission to Damien reason been that Damien only needs to stop and resume the documents for all users in which he does not need to change the printer properties and to assign the permission to print to Sally reason been that Sally only needs to connect to a printer and to print documents in which she will then stop and resume her own print jobs.

Denise is using Outlook 2016 in a business environment. Her company operates a Microsoft Exchange email server.

When Denise uses the address book, which tool is she using by default?

Offline Address Book
Personal Address Book
Global Address List
Custom Address List

Answers

Answer:

Custom Address link

Explanation:

Answer:

D custom address list

Explanation:

Edge 202

Explain to Alana why she might not want to blast her boss on social media just yet.

Answers

Answer: She might get fired. And who knows, if she doesn't, she might get a raise!

What is the thickness of a character’s outline called

Answers

Answer:

actually is answer is font weight

hope it helped!

Write a recursive function named double_digits that accepts an integer as a parameter and returns the integer obtained by replacing every digit with two of that digit. For example, double_digits(348) should return 334488. The call double_digits(0) should return 0. Calling your function on a negative number should return the negation of calling it on the corresponding positive number; for example, double_digits(-789) should return -778899.

Answers

Answer:

A recursive function known as double-digit is a function that accepts as a parameter and returns the integer that is obtained by changing each digit with double digits. For example 425 should be return as 442255.

In the given scenario

the function will be as follow

If

def double_digits:

n < 0:

return -1 * double_digits ( -1 * n )

elif n = 0

return o

else:

result

double_digits ( n // 10 )

return int ( str ( result ) + str ( n % 10 ) + str ( n % 10 )

Test the function as follow

print ( double_digits ( 348 ) )

Result

334488

Test the function as follow

print ( double_digits ( 0 ) )

Result

0

Test the function as follow

print ( double_digits ( -789 ) )

Result

-778899

Janet needs to flag a message for follow-up in Outlook. Which option is not a default?

Today
Tomorrow
Next Week
Next Tuesday

Answers

Answer:

Explanation:

Today

Answer:

Next tuesday.

Explanation: Its to specific

Jorge is sending a message to Thomas but would like a copy sent to his external email address as well. Jorge does not want Thomas to see this copy that was sent.

Which mail field will Jorge use to achieve this goal?

To:
From:
CC:
BCC:

Answers

Answer:  BCC (fourth choice)

=================================================

Explanation:

CC stands for "carbon copy".

BCC stands for "blind carbon copy".

Filling out forms is a tedious process. It's even more tedious when you have to repeat yourself multiple times. Carbon copy paper technology allows you to fill out one form and have those inputted entries be copied to the layers below. In terms of email, a carbon copy (CC) email is just an email sent to more than one person. In the CC line, recipients can see who the other people are in the email chain.

In contrast, a blind carbon copy is where the recipients cannot see who is in the BCC line. This allows Jorge to send the message copy to an external address without Thomas knowing.

How many times will line 7 be executed when the following code is run?


String str = "rebellion";

int i = 0;

int j = str.length() - 1;

String result = "";

while (i < j)

{

result = str.substring(i, i + 1) + result + str.substring(j, j + 1);

i++;

j--;

}

System.out.println(result);
(Java)

Answers

Answer:

4 times

Explanation:

Required.

How many times will line 7 be executed?

Line 2 initialises i to 0

Line 3 subtracts 1 from the length of "rebellion" , the result of the subtraction is then saved in J

So:

j = 9 - 1

j = 8

From line 2 and line 3, we have that:

i = 0 and j = 8

Line 4 is an iteration that is repeated as long as i is less than j

Line 7 will be executed, for the first time as: i < j because 0 < 8

i is incremented to 1 and j is reduced to 7

Line 7 is then executed again, the second time because 1 < 7

i is incremented to 2 and j is reduced to 6

Line 7 is then executed again the third time because 2 < 6

i is incremented to 3 and j is reduced to 5

Line 7 is then executed again the fourth time because 3 < 5

i is incremented to 4 and j is reduced to 4

At this stage, line 7 will no longer be executed because I is no longer less than as 4 = 4.

Hence, number of execution is 4 times

Other Questions
Given w= 2(cos(pi/4)+isin(pi/4)) and z=2(cos (pi/2)+i sin (pi/2)) what is w-z expressed in polar form? Sewtfi951 Corporation makes an extra large part to use in one its fabulous products. A total of 14,500 units of this extra large part are produced and used every year. The company's costs of producing the extra large part at this level of activity are below: Per Unit Direct materials $3.20Direct labor $7.80Variable manufacturing overhead $8.30Supervisor's salary $3.70Depreciation of special equipment $2.10Allocated general overhead $7.30An outside supplier has offered to make the extra large part and sell it to Sewt1951 for $32.30 each If this offer is accepted the supervisor's salary and all of the variable costs, including the direct labor, can be avoided The special equipment used to make the extra large part has no salvage value or other use The allocated general overhead representa fixed costs of the entire Sewt1951 company. none of which would be avoided at the part were purchased instead of produced internally. In addition, the space used to make the extra large part could be used to make more of one of the company's other fabulous products, generating an additional segment margin of $34,500 per year for that product What would be the annual financial advantage (disadvantage) for Sewt1951 Corp as a result of buying the extra large part from the outside supplier? Which of the following examples best illustrates a way in which land is being used as a resource? A. Crude oil, an important source of energy, is now extracted from beneath the ocean floor. B. Natural vegetation is cleared to make room for the construction of a new neighborhood. C. The prairies in South Dakota are home to the largest species of groundhog. D. New cities are now being built on waterI need this really soon so if you have the answer please say it (10 POINTS) The 60s and 70s:The 1970s energy crisis revealed all of the following facts about the American economy except ______.A. America consumed more oil than it could sustainably produce.B. OPEC had the power to regulate a valuable natural resource.C. (Incorrect)D. American oil production was enough to meet all of the country's needs. At Supply World, 4 pens cost $10.00. How much do 3 pens cost if the price per pen is the same? Looking for geometry proof help on a problem with parallelograms and an isosceles triangle Who invented the modern printing press? Question 49 options: Johannes Gutenberg Albrecht Drer Jan Van Eyck Martin Luther Which is the best example of analysis paragraph in the essay? Until after the Korean War, African American soldiers typically served in units thatA. remained segregated from white unitsB. operated combat artillery What is 27 times 30 to the power of 2?(real question) Which allotrope of phosphorus has less ignition temperature? pages in a book are numbered from 1 to 1001. How many times does the number 0 appear? what is measurement A student calculates the density of an unknown metal sample to be 8.25 g/cm3Which set of data from the student's notebook correctly calculates the density of her unknown metal sample?AMass = 165.2 g, Volume = 21.2 cm3.Mass = 198.0 g. Volume = 24.0 cm3Mass = 82.5 g. Volume = 11.0 cm3D.Mass = 202.5 g. Volume = 25.0 cm3 confused :( please help!!!!angles are confusing aaaaaa A space probe recovered an 8.5-kg sample of rocks from the surface of Mars. The acceleration due to gravity on Mars is 3.7 meters per second squared. What is the weight of the sample of rocks on the surface of the earth? application of biopsy will mark brainliest! "Who is responsible for filing a U-5 Form with IARD when an investment adviser representative is terminated and associates with another advisory firm?" Please help me ...........................