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
Write two sentences but each one having either computer in it or technology in it. You can use a word more than once in a senten
Ksju [112]

Answer:

Sentences:

1.My computer has a virus

2.Technology may take over the world someday

Explanation:

7 0
2 years ago
Read 2 more answers
Give four examples of devices which are both<br>Input and Output to a Computer.​
myrzilka [38]

Answer:

HDMI ,I only have one answer to this question

4 0
2 years ago
um I'm new and I just sign up like right now and brainly says I've reached my daily limit for my questions why?
Natalija [7]

Answer:

Im not sure why but maybe you can find a way to contact the people who own it and see if they know because that hasn't happened to me. How many questions have you asked

Explanation:

7 0
2 years ago
2. Write a program with a function that accepts a string as an argument and returns a copy of the string with the first characte
Oduvanchick [21]

Answer:

Following are the code to this question:

def capital(val):#defining a method that takes string value as parameter

   x=True#defining boolean variable

   r=''#defining string variable  

   for i in val:#defining loop to convert the first character into upper case

       if i.isalpha() and x:#defining condition to check input value is string

           r=r+i.upper()#change value into uppercase and hold value in r variable

           x=False#assign value false in boolean variable

       elif i=='.' or i=='?' or i=='!':#check symbols

           r=r+i#add value in r variable

           x=True#assign value True in boolean variable

       else:

           r=r+i#add all value in r variable

   return r#return r variable value

val=input()#input value in val variable

print(capital(val))#called the function which print the return value

Output:

please find the attachment.

Explanation:

  • In the above python program, a method "capital" is declared, which accepts a "val" a string value in its parameter, and inside the method one boolean "x" and one string "r" variable is used, in which r stores return value.
  • In the next step, for loop is declared, inside the loop, the conditional statement is used, in if the block it checks string value and converts the first character into upper case and assigns value false in the boolean variable.  
  • In the next step, elif block is defined that adds value in r variable and at the last, it will return function value, at the last step "val" variable is declared that input value from the user and pass into the method and print its return value.

4 0
2 years ago
Write a class named Book containing: Two instance variables named title and author of type String. A constructor that accepts tw
andrey2020 [161]

Answer:

The code to this question can be given as:

Code:

public class Book  //define class.  

{

private String title, author;   //define variable.

Book(String a, String b)  //define parameterized constructor.

{

title = a;   //holding value.

author = b;

}

public String toString()  //string function

{

return title + "\n" + author;    //return value.

}

}

Explanation:

In the above java code firstly we declare the class book that name is already given in the question. Then we declare the private variable that datatype is string author and title. Then we declare the parameterized constructor. In the parameterized constructor we use the private variable for hold constructor parameter value. Then we declare the tostring() function in this function we return value of the title and author variable.

3 0
2 years ago
Other questions:
  • What color model should Joe use if he will be using an offset printing press?
    7·1 answer
  • Which encryption standard goes with the WPA2 protocol?<br> AES<br> DES<br> TKIP<br> WPS
    10·1 answer
  • The physical parts of the computer that you can see and touch are called______.
    5·1 answer
  • Write a program in C/C++ to draw the following points: (0.0,0.0), (20.0,0.0), (20.0,20.0), (0.0,20.0) and (10.0,25.0). For this
    6·1 answer
  • If cell G7 contains the function ________, it states that if the value in cell C3 is 9, the number 7 will be assigned to cell G7
    6·1 answer
  • How does abstraction help us write programs
    11·1 answer
  • Using filtering as a strategy to deal with information overload requires Group of answer choices reviewing all unsolicited infor
    14·1 answer
  • What happens to a message when it is deleted?
    5·2 answers
  • Read the scenario below, and then choose the right type of computer for each person from the drop-down menus. Three of your frie
    12·1 answer
  • What do we call the software which programmers use to program?​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!