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
Vlad1618 [11]
2 years ago
13

Hello again, just need help debugging-I honestly have no idea how the "isSpace" etc methods work and I've tried various syntaxes

(string name, Character., etc.) to no avail. Also getting errors for the c= sections for converting between char, string, and boolean which I understand, just dont know how to fix. I'm aware I could condense my initial variables, I just like them laid out. The code aims to count lowercase vowels, all consonants, spaces, and punctuation. Anything else will get thrown into a misc count.
import java.util.Scanner;

public class MyClass {

public static void main(String args[]) {
Scanner s=new Scanner(System.in);
System.out.println("input the string");
String as=s.nextLine();

int cons=0;

int a=0;

int e=0;

int i=0;

int o=0;

int u=0;

int space=0;

int punc=0;

char c;

int misc=0;

for(int k=0;k(LESS THAN)as.length();k++){
if(as.isSpace(as.charAt(i))){
space++;
}

else if(as.isConsonant(as.charAt(i))){

cons++;

}

else if(as.isPunctuation(as.charAt(i))){

punc++;

}

else if(as.isVowel(as.charAt(i))){

c=as.charAt(i);

if (c="a"){

a++;

}

else if(c="i"){

i++;

}

else if(c="e"){

e++;

}

else if(c="o"){

o++;

}

else if(c="u"){

u++;

}

else{

misc++;

}

}

else{

misc++;

}

}

System.out.println(a+" a's");

System.out.println(e+" e's");

System.out.println(i+" i's");

System.out.println(o+" o's");

System.out.println(u+" u's");

System.out.println(space+" spaces");

System.out.println(punc+" punctuations");

System.out.println(cons+" consonants");

System.out.println(misc+" misc. (uppercase vowels, etc.");


}

}
Computers and Technology
1 answer:
Julli [10]2 years ago
5 0

import java.util.Scanner;

public class JavaApplication81 {

   

   public static void main(String[] args) {

       Scanner s = new Scanner(System.in);

       System.out.println("Input the string");

       String as = s.nextLine();

       int cons = 0;

       int a = 0;

       int e = 0;

       int i = 0;

       int o = 0;

       int u = 0;

       int space = 0;

       int punc = 0;

       char c;

       int misc = 0;

       String punctuation = ".!,?";

       String consonants = "bcdfghjklmnpqrstvwxyz";

       for (int k = 0; k < as.length(); k++){

           c = as.charAt(k);

       if (Character.isWhitespace(c)){

           space ++;

       }

       else if (punctuation.indexOf(c) != -1){

           punc++;

       }

       else if (consonants.indexOf(c) != -1){

           cons++;

       }

       else if (c == 'a'){

           a++;

       }

       else if(c == 'e'){

           e++;

       }

       else if (c == 'i'){

           i++;

       }

       else if (c == 'o'){

           o++;

       }

       else if (c == 'u'){

           u++;

       }

       else{

           misc++;

       }

       

   }

       System.out.println(a+" a's");

       System.out.println(e+" e's");

       System.out.println(i+" i's");

       System.out.println(o+" o's");

       System.out.println(u+" u's");

       System.out.println(space+" spaces");

   

       System.out.println(punc+" punctuations");

       System.out.println(cons+" consonants");

       System.out.println(misc+" misc. (uppercase vowels, etc.");

   }

   

}

This is one example of how it could be done.

You might be interested in
Which of the following is a step in paraphrasing? Skim the original information to get a sense of what it is about. Select a few
Sedaia [141]
Select a few key words to change to your own words
4 0
3 years ago
Read 2 more answers
Students can use eNotes to type notes directly on screen and
zalisa [80]
A. review or print them later
6 0
3 years ago
Read 2 more answers
Structure for forloop?
solong [7]

Answer:

for ( initialization; condition;increment)

{

code goes here;

}

in python:

for i in list/range:

code with proper indentation

By initialization above we mean, like int i=0; etc.

By condition like i<10;

and by increment it means like i++, ++i or i+=1; etc

And in python, i can be an integer value if the range is mentioned, and it can be an item of a list if the list is used. We can also use an array, string and various other data structures in python. like we can have characters in a string and so on.

Explanation:

Please check the answer section.

8 0
3 years ago
What will the following code display? #include using namespace std; void doSomething(int); int main() { int x{2}; cout &lt;&lt;
Leno4ka [110]

Answer:

The code will display the following on the screen:-

2

0

2

Explanation:

The output is like this because x{2} assigns the value 2 to the integer x.First the value of x is printed on the screen that is 2 and that newline is used to go to the next line.After that function is called doSomething with x passed as the argument. doSomething function assigns the value zero to the variable passed and prints it on the screen.So the next line is 0.Since x is passed by value so no changes will appear in the original argument.Hence the last line printed is 2.

8 0
2 years ago
What is the purpose of the domain name system
SpyIntel [72]

Answer:

The Domain Name System (DNS) is a central part of the internet, providing a way to match names (a website you're seeking) to numbers (the address for the website). Anything connected to the internet - laptops, tablets, mobile phones, websites - has an Internet Protocol (IP) address made up of numbers.

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • The number of operations executed by algorithms A and B is 40n2 and 2n3, respectively. Determine n0 such that A is better than B
    12·1 answer
  • Consider the attack scenario given below:
    8·1 answer
  • What is a flash player?
    9·2 answers
  • You want to discard your old computer and want to securely erase the data from your hard drive. What can you use to do this and
    6·1 answer
  • A security policy is a
    11·1 answer
  • There is usually a positive side and a negative side to each technology improvement. Select a technology you use every day and c
    5·1 answer
  • You are the leader of a team at work. What type of leader would you like to be – one that gets involved and works with the team
    15·2 answers
  • Good ways to increase sales on phone accesories?
    10·2 answers
  • 5. What skill is unique to reading online?
    14·1 answer
  • What is cloud computing?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!