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
From the practice directory, you wish to capture a listing of files and directories to a file in your user2 directory, thus allo
MArishka [77]

Answer:

variable(s) determine the amount of potential energy an object has?

Explanation:

6 0
3 years ago
Which of the following<br> Services are<br> functions performed<br> by the general office?
GaryK [48]

Answer:

comment the choices please

6 0
2 years ago
To use an automated teller machine (ATM), a customer must enter his or her four-digit Personal Identification Number (PIN). How
schepotkina [342]

Answer:

10000 possible PINs.

Explanation:

Considering the fact that only numbers are permitted (0 - 9) which gives 10 characters and also that the digits can be repeated, the total number of possible PINs that are possible is 10 x 10 x 10 x 10 = 10000

6 0
3 years ago
Assume you're using a three button mouse. to access shortcut menus you would
jekas [21]
<span>Normally you would click the right hand/secondary mouse button but you may configure any of the buttons to work within the Keyboard and Mouse section of System Preferences.</span>
7 0
3 years ago
Specialized programs that allow particular input or output devices to communicate with the rest of the computer system are calle
In-s [12.5K]
Hi!

These programs which allow a peripheral device to interact with the rest of the computer system are going to be <em>device drivers.</em>

Hopefully, this helps! =)
3 0
3 years ago
Other questions:
  • What is a valence orbit?
    13·2 answers
  • The strFirstName and strLastName variables contain the strings "Jane" and "Jones," respectively. Which of the following statemen
    14·1 answer
  • Mathematical computations by a computer are faster than your quickest mathematical computations because the top speed of a neura
    13·1 answer
  • While inserting images, the Picture command is usually used to insert photos from a digital camera, and the Clip Art command is
    7·1 answer
  • Which of the following is not a true statement? You can import a table or a query directly from an Access database into an Excel
    15·1 answer
  • What’s the purpose of balancing or monitoring your checking account?
    12·2 answers
  • Computing hardware, computers using vacuum tubes were called the first generation; transistors and diodes, the second; integrate
    9·1 answer
  • Select the correct answer.
    9·2 answers
  • Write the Number class that can be used to test if the number is odd, even, and perfect. A perfect number is any number that is
    10·1 answer
  • Which internet explorer security feature restricts the browsing session information that can be tracked by external third-party
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!