I'm just trying to count letters, by type etc. What am I doing wrong here?
import javax.swing.JOp tionPane;
public class Asg3
{
public static void main(String[] args)
{
int aCount=0, eCount=0, iCount=0, oCount=0, uCount=0, upperCount=0;
int lowCount=0, spaceCount=0, otherCount=0, totalCount=0;
char currentChar;
char c;
int position= 0,size =0;
String charInput;
charInput = JOptionPane.sho wInputDialog (null, "Enter a sentence...plea se");
size = charInput.lengt h();
// now that everything has a value, lets get a loop going
while (position < size)
{
c = charInput.charA t(position);
switch (c)
{ Get : expected case 'b':case 'B':case 'c':case 'C':case 'd':case 'D':case 'f':case 'F';
otherCount++;
break;
case 'f':case 'F':case 'g':case 'G':case 'h':case 'H':case 'j':case 'J':
otherCount++;
break;
case 'k':case 'K':case 'l':case 'L':case 'm':case 'M':case 'n':case 'P':
otherCount++;
break;
case 'q':case 'Q':case 'r':case 'R':case 's':case 'S':case 't':case 'T':
otherCount++;
break;
case 'v':case 'V':case 'w':case 'W':case 'x':case 'X':case 'y':case 'Z':
otherCount++;
break;
case '.':case '!':case '?':case ',':case '$':case '@':case '&':case ':':
otherCount++;
break;
case 'a':case 'A':
aCount++;
break;
case 'e':case 'E':
eCount++;
break;
case 'i':case 'I':
iCount++;
break;
case 'o':case 'O':
oCount++;
break;
case 'u':case 'U':
uCount++;
break; Get : expected case ' ';
spaceCount++;
break;
}
position++;
}
totalCount= size;
System.out.prin t("There are " + aCount + " a's, " +eCount + " e's, ");
System.out.prin t(iCount+ " i's, " + oCount+ " o's, and " + uCount);
System.out.prin t("u's and " + iCount+ " i's, " + oCount+ " o's, and ");
System.out.prin t(+ uCount+ " u's and " + otherCount + " other letters and"); get ')' expected System.out.prin t(+ spaceCount + " spaces and " totalCount + "total asccis");
}
}
Any ideas? Thanks
1 1405
I'm just trying to count letters, by type etc. What am I doing wrong here?
import javax.swing.JOp tionPane;
public class Asg3
{
public static void main(String[] args)
{
int aCount=0, eCount=0, iCount=0, oCount=0, uCount=0, upperCount=0;
int lowCount=0, spaceCount=0, otherCount=0, totalCount=0;
char currentChar;
char c;
int position= 0,size =0;
String charInput;
charInput = JOptionPane.sho wInputDialog (null, "Enter a sentence...plea se");
size = charInput.lengt h();
// now that everything has a value, lets get a loop going
while (position < size)
{
c = charInput.charA t(position);
switch (c)
{ Get : expected case 'b':case 'B':case 'c':case 'C':case 'd':case 'D':case 'f':case 'F';
otherCount++;
break;
case 'f':case 'F':case 'g':case 'G':case 'h':case 'H':case 'j':case 'J':
otherCount++;
break;
case 'k':case 'K':case 'l':case 'L':case 'm':case 'M':case 'n':case 'P':
otherCount++;
break;
case 'q':case 'Q':case 'r':case 'R':case 's':case 'S':case 't':case 'T':
otherCount++;
break;
case 'v':case 'V':case 'w':case 'W':case 'x':case 'X':case 'y':case 'Z':
otherCount++;
break;
case '.':case '!':case '?':case ',':case '$':case '@':case '&':case ':':
otherCount++;
break;
case 'a':case 'A':
aCount++;
break;
case 'e':case 'E':
eCount++;
break;
case 'i':case 'I':
iCount++;
break;
case 'o':case 'O':
oCount++;
break;
case 'u':case 'U':
uCount++;
break; Get : expected case ' ';
spaceCount++;
break;
}
position++;
}
totalCount= size;
System.out.prin t("There are " + aCount + " a's, " +eCount + " e's, ");
System.out.prin t(iCount+ " i's, " + oCount+ " o's, and " + uCount);
System.out.prin t("u's and " + iCount+ " i's, " + oCount+ " o's, and ");
System.out.prin t(+ uCount+ " u's and " + otherCount + " other letters and"); get ')' expected System.out.prin t(+ spaceCount + " spaces and " totalCount + "total asccis");
}
}
Any ideas? Thanks
Please inclose the code you have posted in codetags...
About your problem, You forgot to check all cases that must end with a colon, not semi-colon... - get ')' expected System.out.print(+ spaceCount + " spaces and " totalCount + "total asccis");
-
}
You forgot to fix the combinations of Strings and variables...
a "+" is required....
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: mike420 |
last post by:
In the context of LATEX, some Pythonista asked what the big
successes of Lisp were. I think there were at least three *big*
successes.
a. orbitz.com web site uses Lisp for algorithms, etc.
b. Yahoo store was originally written in Lisp.
c. Emacs
The issues with these will probably come up, so I might as well
mention them myself (which will also make this a more balanced
|
by: skhairnar |
last post by:
Hi All,
We are getting following error while compiling sources with SUN WS6U2,
any idea how to resolve this error?
"/opt/SUNWspro/WS6U2/include/CC/Cstd/rw/rwstderr.h", line 39: Error:
namespace is not defined.
"/opt/SUNWspro/WS6U2/include/CC/Cstd/rw/rwstderr.h", line 39: Error:
"," expected instead of "{".
We has seen couple of solutions for similar errors:
|
by: Si |
last post by:
I'm writing an HttpModule to intecept web method calls and retrieve
custom authentication information from their SOAP headers.
I have the httpModules tag in web.config and that appears to be getting
parsed okay. If I mangle the type attribute or try to add the module
twice I get configuration errors as expected. So I "assume" that the
module is getting loaded.
Init() is not getting called, though, when I make a call to a web
method...
|
by: clintonb |
last post by:
Some programmers, and even Microsoft documents, say you should only
throw exceptions for exceptional situations. So how are others
handling all the other unexceptional errors? How are you propagating
errors up the call stack?
In the past, in my C++ code, I used to throw exceptions for ALL errors,
exceptional or not. It seemed like a nice clean method for detecting,
handling, and propagating errors. You can find multitudes of articles...
|
by: Paul Taylor |
last post by:
Hello, I wonder if anyone can help with this.
I have an ASP.NET 2.0 site that runs correctly on the local machine inside
or outside of the IDE. When I build the site, it produces some warning
messages, but no errors. When I come to Publish the site, it fails during
precompilation with three "BC30182: Type Expected" errors. The output trace
is below:
*********** BEGIN TRACE
| |
by: donkeyboy |
last post by:
All,
I've tried the jythonc compiler to try and create an applet to see how
it works, but I get a number of Java compile errors that are way above
my knowledge. Does anyone know what any of the following means? I'm
using JDK 1.5.0_09, under Win XP SP2.
Runnnig the file " jython FILENAME" works, so I don't know what's
happening. Any thoughts?
|
by: nemisis |
last post by:
Fish.h
#ifndef FISH_H
#define FISH_H
#include <iostream>
#include <vector>
|
by: Lance Wynn |
last post by:
One of my server has been compromised from this virus, and I can't seem to
block it out! I have shut down the infected server, but I need to figure
out how to check for this, and stop it.
The site is running iis5 on Windows2000, the backend DB is SQLServer 2000
Can anyone point me to some good resources for this? This is urgent!
Thanks alot
Lance
|
by: beet |
last post by:
Hi,
I am really not good at c/c++.
Some simple code..
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "simlibdefs.h"
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |