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.
5
8
<u>Explanation:</u>
<u></u>
Since the number is already defined as 5, greater_than_zero holds the value true and less_than_zero holds the value false because 5 is greater than zero and not less than 0. Since there are 4 four if conditions, only two holds true i.e the first one and the last one because the in third condition we are using and logic which needs both condition to be true to make the condition true, whereas in fourth we are using or logic which can make condition true even if one condition is true. Hence the number printed will be number and number +3.
Answer:
Moore's Law refers to Moore's perception that the number of transistors on a microchip doubles every two years, though the cost of computers is halved. Moore's Law states that we can expect the speed and capability of our computers to increase every couple of years, and we will pay less for them. Another tenet of Moore's Law asserts that this growth is exponential.
Update your virus detection software. - Scan the computer using another virus detection program.
<h3>Which program is used for detecting and removing viruses?</h3>
Antivirus is a kind of software used to prevent, scan, detect and delete viruses from a computer. Once installed, most antivirus software runs automatically in the background to provide real-time protection against virus attacks.
<h3>How can a virus be erased?</h3>
Some computer viruses and other unwanted software reinstall themselves after the viruses and spyware are detected and removed. Fortunately, by updating the computer and by using malicious software removal tools, you can help permanently remove unwanted software.
To learn more about Antivirus , refer
brainly.com/question/17209742
#SPJ4
Answer:
a[j] = 2*a[j+1];
Explanation:
The statement above assigns a new value to the element of the array indexed by j. The new value should be equal to twice the value stored in the next element of the array.