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
ivann1987 [24]
3 years ago
14

I'm stuck on this Java exercise problem and don't know how to organize my code with proper formatting and it's not helping that

I'm pretty terrible at logic. I can't figure out how to return the number of spaces to be displayed in the main method.

Computers and Technology
1 answer:
Volgvan3 years ago
4 0

In your "count spaces method" before the for loop, you want to declare an int variable (let's call it spc)

then, each time you find that charat, spc++.


also, the string must be declared in the main method, not the spaces count method.


The actual code:


public class CountSpaces{

public static void main(String[] args){

String instring = "(your quote here)";

int spaces = calculateSpaces(instring);

System.out.println("The number of spaces is " + spaces);

}

public static int calculateSpaces(String in){

int spc = 0;

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

if(in.charAt(i)== ' '){

spc++;

}

}

return spc;

}

}


that should be it.  If you have any questions, feel free to reach out.

You might be interested in
A raised dot (ú) shows where the enter key was pressed. true or false.
Yakvenalex [24]
False i doesnt  shows anything like this


6 0
3 years ago
The customer's endpoint device on the wan is called the __________________.​
Lelu [443]
<span>The customer's endpoint device on the WAN is called the Data Terminal Equipment (DTA).
WAN 
is wide area network, referring to a network that extends over a large area. DTA is an end instrument which converts information into signals.</span>
3 0
3 years ago
Which type of network is the internet? choose the answer
Alex Ar [27]

Answer:

WAN or wide area network

Explanation:

The Internet is the most basic example of a WAN. It is connecting all computers together around the world.

5 0
3 years ago
A developer wants to take existing code written by another person and add some features specific to their needs. Which of the fo
anzhelika [568]

Answer:

open-source

Explanation:

open-souce software allows any user to submit modifications of the source code

7 0
2 years ago
A researcher is interested in whether working memory is influenced by lack of sleep. The researcher administered a measure of wo
ale4655 [162]

Answer:

Dependent sample t-test

Explanation:

The Dependent sample t-test compares the mean score of measurements in one group to that of another other group. It mainly used when analyzing comparable sample units as it pairs repeatable observations within a time frame.

For example, a researcher administered a measure of working memory to a group of subjects at 8am on Day 1 of the study and then again at 8am on Day 2 of the study, after keeping the subjects awake the entire night.

5 0
3 years ago
Other questions:
  • Is anyone familiar in drawing flow charts for c++ programming
    14·1 answer
  • divide the input array into thirds (rather than halves), recursively sort each third, and finally combine the results using a th
    15·1 answer
  • Notes page view and Outline view are found in the<br> tab.<br> File<br> O Status<br> View<br> Page
    8·1 answer
  • Instructions: Type the correct answer in the box. Spell the word correctly.
    5·2 answers
  • A ___________ is the smallest unit in a written language.
    7·2 answers
  • Match the elements of a web page with their descriptions.
    12·1 answer
  • If an electric circuit has 30ohms and 10amps. How many volts the battery voltmeter should read?
    10·1 answer
  • Multi-part question:
    13·1 answer
  • Is a free verse a poetry that has no images
    5·2 answers
  • Help101111 avatar can we be friend's please? My name is Keegan. what is yours?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!