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
Mark handles the accreditation of applications and systems within his department. He has been told by one of his technicians tha
lorasvet [3.4K]

Answer:

Changes took place

Explanation:

The system changes took place that needs to be re-accredited because, in his department, Mark performs certification of software and computer systems. Some of several specialists have advised him a device needs to be properly-accredited.

So, the system changes have taken place and need to be actually-accredited.

7 0
3 years ago
For robot arms the first three axes are called
Semmy [17]

\huge\purple{Hi!}

Cartesian robots (sometimes called rectilinear or gantry robots) have three linear axes, x, y, z.

6 0
3 years ago
If your teacher is out of the office, what is the best way to reach them, or get help?
liberstina [14]
Send your teacher a portal message, or call them.
8 0
3 years ago
Google is an example of a(n):
Andre45 [30]
Well i see your X so i would say you were correct it is a search engine.
7 0
3 years ago
Fiber optic cable from a service provider can be delivered directly to the end user. which implementation delivers data to a cab
Kryger [21]

An implementation which delivers data to a cabinet for distribution is: FTTN.

<h3>What is a fiber optic cable?</h3>

A fiber optic cable can be defined as a type of wired connector which are either made of glass or plastic and they are typically used for connecting one network device to another, so as to form a computer network and enable the continuous transmission of data between them.

<h3>What is FTTN?</h3>

FTTN is an abbreviation for Fiber To The Neighborhood and it can be defined as a type of fiber technology that is designed and developed for directly delivering data to a single physical cabinet that serves end users (population).

In conclusion, an implementation which delivers data to a cabinet for distribution is Fiber To The Neighborhood (FTTN).

Read more on fiberoptic cables here: brainly.com/question/116766

#SPJ1

3 0
2 years ago
Other questions:
  • ASAP
    12·1 answer
  • What is computer hacking? describe some examples
    6·1 answer
  • A device in electricity that is analogous to a restriction in a water pipe is:
    11·1 answer
  • PLEASE HELP ASAP!!! 50 POINTS FOR TWO DIGITAL TECHNOLOGY MULTIPLE CHOICE QUESTIONS!!!
    13·1 answer
  • Quality of service (QoS) is a technology that allows a network design to strategically optimize network performance for select t
    8·2 answers
  • Determine the number of character comparisons made by the brute-force algorithm in searching for the pattern GANDHI in the text
    7·1 answer
  • Which of the following statements is FALSE?
    5·1 answer
  • F. Practical Questions
    7·1 answer
  • (b) A mouse is a display device. (c) A monitor is a television.​
    10·1 answer
  • Hey how was your day 50 points
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!