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
zlopas [31]
2 years ago
11

What output is produced by the following program segment? Why? (Recall that name.charAt(i) is the i-th character in the string,

name.)
String name;
int i;
boolean startWord;

name = "Richard M. Nixon";
startWord = true;
for (i = 0; i < name.length(); i++) {
if (startWord)
System.out.println(name.charAt(i));
if (name.charAt(i) == ' ')
startWord = true;
else
startWord = false;
}
Computers and Technology
1 answer:
vekshin12 years ago
8 0

Answer:

The output is:

R

M

N

Explanation:

The code snippet print the beginning letter of each word in the given name.

In the for loop snippet:

first the program check if startWord is true and it is true, then it print the value of the character at index 0. Then it check if value of character is empty. If it is empty, startWord is initialized to true else it is initialized to false.

The loop only print a character when the value of i are 0, 8 and 11 which are also the beginning character of a word.

You might be interested in
Write code that uses the input string stream inss to read input data from string userinput, and updates variables usermonth, use
mr Goodwill [35]

Answer:

It will be a java code.

Explanation:

import java.util.Scanner;

public class StringInputStream {

    public static void main (String [] args) {

        Scanner inSS = null;

        String userInput = "Jan 12 1992";

        inSS = new Scanner(userInput);`

        String userMonth = "";

        int userDate = 0;

        int userYear = 0;

        /* Your solution goes here  */

        System.out.println("Month: " + userMonth);

        System.out.println("Date: " + userDate);

        System.out.println("Year: " + userYear);

        return;

   }

}

3 0
2 years ago
Read 2 more answers
3.34 LAB: Mad Lib - loops in C++
Ganezh [65]

Answer:

A Program was written to carry out some set activities. below is the code program in C++ in the explanation section

Explanation:

Solution

CODE

#include <iostream>

using namespace std;

int main() {

string name; // variables

int number;

cin >> name >> number; // taking user input

while(number != 0)

{

// printing output

cout << "Eating " << number << " " << name << " a day keeps the doctor away." << endl;

// taking user input again

cin >> name >> number;

}

}

Note: Kindly find an attached copy of the compiled program output to this question.

7 0
2 years ago
An aviation tracking system maintains flight records for equipment and personnel. The system is a critical command and control s
sergeinik [125]

Answer:

offline backup solution

Explanation:

In such a scenario, the best option would be an offline backup solution. This is basically a local and offline server that holds all of the flight record data that the cloud platform has. This offline backup server would be updated frequently so that the data is always up to date. These servers would be owned by the aviation company and would be a secondary solution for the company in case that the cloud platform fails or the company cannot connect to the cloud service for whatever reason. Being offline allows the company to access the database regardless of internet connectivity.

5 0
1 year ago
What does a sticky CTA do?
Anarel [89]
It encourages users to revisit your website.
5 0
1 year ago
Read 2 more answers
Spark is electrical discharge in air, while air is mix of variety of gases what particles conduct electricity in gas
erastova [34]

Answer:

Mercury, rontgen rays, etc.

Explanation:

There are lots of answers to this question, hope these two help.

6 0
1 year ago
Other questions:
  • The term load is often used to describe opening a page in a ____. Answer
    11·1 answer
  • The piston engine uses the ________ to convert the reciprocating motion of the piston into rotary motion.
    13·1 answer
  • Thomas has signed a deal with a production house that allows them to use his images on their website. What is required when imag
    5·2 answers
  • You'd like to change the minimum password length policy in the Default Domain Policy group policy preference (GPO). What's the b
    10·1 answer
  • Show the stack with all activation record instances, including static and dynamic chains, when execution reaches position 1 in t
    10·1 answer
  • Se dau lungimile a N cuvinte (0 &lt; N ≤ 5 000), formate din cel puțin un caracter. Să se afișeze lungimea minimă necesară R a u
    14·1 answer
  • A variable like userNum can store a value like an integer. Extend the given program to print userNum values as indicated. (1) Ou
    15·1 answer
  • Select all the activities Samil could so through his banking app.
    5·2 answers
  • 1.21 LAB: Divide by x
    13·2 answers
  • Import simplegui
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!