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 utility program that makes a copy of all files or selected files that are in the libraries is called ______
sleet_krkn [62]

Answer: File History

8 0
3 years ago
Tamara is writing a program to organize students in a class and needs to use operators to organize student grades, then compare
VMariaS [17]

Answer:   you said "Tamara needs to use

operators to organize the students' grades, then

operators to compare the results."

i think your right

Explanation:

sounds right.

3 0
2 years ago
A ______ system writes data on two or more disks simultaneously, thereby creating a complete copy of all the information on mult
Mrrafil [7]

A raid 1 and mirrored system writes data on two or more disks simultaneously, thereby creating a complete copy of all the information on multiple drives.

<h3>What is Disk mirroring?</h3>

In data storage, disk mirroring is a term that connote the doubling of logical disk volumes into a different physical hard disks so that it will always be available.

Conclusively, Note that this is mostly used in RAID 1. A mirrored volume is known to be full logical depiction of separate volume copies and as such the answer above is correct.

Learn more about system from

brainly.com/question/25594630

8 0
2 years ago
During an election year, why would a senator want to determine a mode?
ale4655 [162]

Answer:

To determine which issue is most important to the general public.

Explanation:

Took the Edge assignment!

3 0
2 years ago
Create a float variable named circumference.
Likurg_2 [28]

Answer:

Float circumference; // Create a float variable

Explanation:

The float datatype is used for storing the decimal point values .The syntax  to declaring  any float variable is given below.

float variable-name;

float  circumference; // create a float variable

circumference=89.9007;; // store the value in circumference

Following are program in c++

#include <iostream> // header file

using namespace std; //namespace

int main() // main function

{

   float circumference; // creating variable float

   circumference=89.9007; // storing value

   cout<<circumference;  // display value circumference

   return 0;

}

Output:

89.9007

5 0
2 years ago
Other questions:
  • Which of these statements is true?
    9·1 answer
  • LOOK TO THE LEFT AND RIGHT BEFORE ENTERING ANY INTERSECTION ON A GREEN LIGHT BECAUSE:
    12·2 answers
  • One is FPGA and other is ASIC. Budget, power consumption, and speed are the common parameters considered for the selection of th
    9·1 answer
  • Word's Help feature is useful if you need to quickly learn how to print a document
    14·1 answer
  • Which of the following is an example of a query with an explicit location? Select all that apply. True False [walmart boston], E
    7·2 answers
  • What steps should Jeremy take to get himself motivated to study for the test?
    12·2 answers
  • You are a technical support engineer and provide help desk support for the network in a manufacturing company. You receive a cal
    10·1 answer
  • Which tasks can be completed using the Chart Tools Design tab? Check all that apply.
    9·1 answer
  • Can some one help me i do not now how to give a BRANLEST. if you help i will give you one BRANLEST.
    7·2 answers
  • Bloxburg Build can anyone help me
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!