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
One of the main responsibilities employers have under OSHA is to:
poizon [28]
What dose osha means please
7 0
3 years ago
Read 2 more answers
The IT director instructed the systems administrator to build a server to support the accounting department's file growth. The I
Mamont248 [21]

Answer:

Option (C) FAT32 File System Type

Explanation:

  • FAT32 File System Type cannot be encrypted by the accounting users.
  • FAT stands for File Allocation Table. It is a file system architecture.
  • The File Allocation Table is an index table which contains the details about each cluster ( disk storage space ).
  • By traversing the File Allocation Table, the operating system gets the details the file ( where it is located ) and the size of the file.
  • The FAT32 file system contains more number of possible clusters.
  • In this system, 32 bits are used to store the total number of possible clusters.
  • In FAT32 file system, the transparent encryption is not supported.
  • So, option (C) is correct.
  • All other options are wrong options.
3 0
3 years ago
Nowadays computer games are mostly available on external<br> hard disk.<br> Is it true or false?
sergey [27]

Answer:

false

Explanation:

because a lot of times they are downloads without the disk

7 0
3 years ago
Read 2 more answers
What happens when an exception is thrown, but the try statement does not have a catch clause that is capable of catching it?
Pavlova-9 [17]

Answer:

A checked exception indicates something beyond your control has gone wrong. ... If an exception does not have a matching catch clause, the current method terminates and throws the exception to the next higher level. If there is no matching catch clause at any higher level, then the program terminates with an error.

6 0
3 years ago
Example 4-1: The styles for the main content of an HTML document main { clear: left; } main h1 { font-size: 170%; } main h2 { fo
jek_recluse [69]

Answer:

The clear property stops floating of the main element to the right of the preceding block elements

Explanation:

The clear property specifies that which sides of the elements floating element are not allowed to be float.

It returns or sets the positions of an element in relation to the floating objects. If an element can be fitted horizontally in space next to other elements which is floated.

Syntax:

clear: none | left | right | both | initial;

6 0
2 years ago
Other questions:
  • In the Remote Access Domain, if private data or confidential data is compromised remotely, you should set automatic blocking for
    5·1 answer
  • Please help?!
    11·2 answers
  • - Explain the Windows User Authentication process for Client connecting to the domain
    11·1 answer
  • What is a good safety precaution to take when opening a computer case?
    9·1 answer
  • a limited-access expressway. A)allows vehicles to enter or exit only at certain place.B) does not permit trucks or buses.C)has n
    9·1 answer
  • Few companies today could realize their full-potential business value without updated ________. Select one: a. IT investments ma
    10·1 answer
  • 10. This famous designer’s sister took over his clothing line after his assassination in 1997.
    9·1 answer
  • Sarah is a detail-oriented programmer. While testing her program, what other skill would she have to apply in order to detect al
    11·1 answer
  • How to solve household arithmetic​
    7·1 answer
  • (b) Cell B12 contains the formula, ROUND((SUM(B5:B9)*D1),1).
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!