Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java programming

Name: Anonymous 2006-09-21 10:55

Hi y'all,

I'm new to Java and we just started on the else/if statements. I'm not good when it comes to programming, and this is my first programming language.

This is the actual homework problem:

Create a program with a dialog box that will use letters a, b or c in the code to recognize the first letter of a word and then will output a statement.

For example if the dialog were to ask, "Please enter your first name" and Andrew was entered.

The program could output, "Apples begin with your first letter, Andrew."
A word, such as Apples would be assigned for each letter a, b and c.
___________________________________________________________________
___________________________________________________________________

And here is my code:

import java.util.Scanner;

public class namesAndFruit
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);

char a = string.charAt(0);
char b = string.charAt(0);
char c = string.charAt(0);

String a = apple;
String b = banana;
String c = cantalope;

System.out.print("Please enter your first name: ");
String firstName = input.next();
System.out.println("Your name is " + firstName);

if(Character.isLetter(a))
System.out.println(+a "begins with your first letter, " + firstName);

if(Character.isLetter(b))
System.out.println(+b "begins with your first letter, " + firstName);

if(Character.isLetter(c))
System.out.println(+c "begins with your first letter, " + firstName);

}
}
____________________________________________________________________
____________________________________________________________________

And here is the error messages when I compiled them:


D:..is222..names..>javac *.java

namesAndFruit.java:23: ')' expected
System.out.println(+a "begins with your first letter, " + firstName);
^
namesAndFruit.java:26: ')' expected
System.out.println(+b "begins with your first letter, " + firstName);
^
namesAndFruit.java:29: ')' expected
System.out.println(+c "begins with your first letter, " + firstName);
^
3 errors

___________________________________________________________
___________________________________________________________

I wish I can post my code correctly here with the line numbers, but I don't know how. From what I've seen in this group, you guys/gals are really smart and insightful.

Thank you!!!
Josephine

Name: Anonymous 2006-09-21 12:22

>>3
>Why oh why do they start the kids on Java?

Because it's one of the cleanest languages available.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List