Hi! I'm using Eclipse as an IDE, I need to code a program where users enter a string and it computes the count for each vowel, and how many words are in the string. Users can do as many strings as they want until they hit cancel. This is what I have so far: -
import javax.swing.*;
-
public class Program
-
{ //Open Class
-
public static void main(String[] args)
-
{ //Open Main
-
String input, output; //Holds input and output.
-
int aCount = 0, eCount = 0, iCount = 0, oCount = 0, uCount = 0, numLines = 0; //Holds values for entries of respective vowels. All initialized to 0.
-
char v = 0; //v standing for vowel
-
-
String text = null;
-
do
-
{
-
input = JOptionPane.showInputDialog("Input a line to analyze or Cancel to quit: ");
-
input = input.toLowerCase();
-
input.length();
-
numLines = numLines + 1;
-
for (int wCount = 0; wCount < text.length(); wCount++)
-
v = text.charAt(wCount);
-
switch (v)
-
{//Open switch statement. Braces are not used because there is only 1 corresponding statement per case.
-
case 'a':
-
aCount = aCount + 1;
-
break;
-
case 'e':
-
eCount = eCount + 1;
-
break;
-
case 'i':
-
iCount = iCount + 1;
-
break;
-
case 'o':
-
oCount = oCount + 1;
-
break;
-
case 'u':
-
uCount = uCount + 1;
-
break;
-
-
}//Close switch statement
-
JOptionPane.showMessageDialog(null, "A-Count: " + aCount + "\n" + "E-Count: " + eCount + "\n"
-
+ "O-Count" + oCount + "\n" + "U-Count" + uCount + "\n" + "Word Count" + v + "Line Analisys - name here", text, JOptionPane.PLAIN_MESSAGE);
-
}//Close do while
-
while (input != null);
-
-
-
}//Close Main
-
}//Close Class
-
I have no idea where i'm going wrong, or if i'm even headed in the right direction =\
2 4132
So what happens when you (attempt to) compile/run your program?
well
your char variable Declaration
you are missing the single code ' ' on the assign value.
then next
your for loop, i thought the switch block should be under the for block. but on your code you missed to define the for block.
then allright.
regards
chel-1
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Brynn |
last post by:
I want to thank the person that sent the nasty messages to my
contact.asp test page ... you have inspired me !!!
I have now added a bad_words filter both to my JSValidation script
(going up on my site soon) and my contact.asp tool.
I would have forgotten about it if it were not for you. I TRULY
appreciate your help ... and hope that you helping me eats you up
inside ... ROFL.
|
by: mark |
last post by:
hi guys i need hlp on a c programcounting letters,words,etc .simple.
thanks
|
by: gk245 |
last post by:
Basically, i want to make a function that will receive a sentence or
phrase, and count its words.
It would start like this (i think):
#include <stdio.h>
int count ( char sentence )
{
char string ;
|
by: powerej |
last post by:
I have gotten the part of counting how many words are in the string, but the vowels just seem alien to me. Ive tried so many things but never close to a correct answer. I know I need to use charAt() and length() some nested loops with do while and for, but cant seem to get headed in the right direction. Also when i click the cancel button my program is suppose to end and tell you how many lines were entered, a count of vowels from all lines...
|
by: arnuld |
last post by:
any comments for improvement:
/* C++ Primer - 4/e
*
* CHAPTER 10 - Associative Containers
*
* EXERCISE - 10.7
* Write a program to count and print the number of times each word
* occured in the input.
*
| |
by: Franzi |
last post by:
Hello,
how can I count words in Word alphabetically? So that it shows me how many words of each letter I have (shown in the alphabetical order).
Thank you!
|
by: ashpats |
last post by:
Hey everyone,
I am supposed to write a program that counts the number of vowels in string of characters.
It must include "Struct counter_t (it must be declared as in the code i've written)" and function "int CountVowels (IN text, OUT Count)". the OUT parameter must be of type counter_t. I've written the code but it doesn't seem to work. Can someone help me please???
...
|
by: HypeBeast McStreetwear |
last post by:
Hi I'm supposed to be writing a program that counts in a given text, the words that contain at least three different vowels (a,e,i,o,u)
For my test run I have to use "unquestionably", but I can't anything to work. Here's what I have so far.
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
|
by: tpgames |
last post by:
I do not understand why this code does not work? It will show ????? for the word length, but will does not actually access the individual letters within the word list. I enter the vowels as guesses, and NONE of the vowels are said to be in the word. I'm trying to put the working code in a separate JS file, instead of having the silly thing on the same HTML page. This might allow me to incorporate user choosing which game to play within the same...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |