There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen boot computer connection crash css dell drive driver drivers email error ethernet excel explorer firefox firefox 3 freeze game hard drive internet internet explorer itunes laptop malware monitor network networking nvidia outlook outlook 2003 outlook express partition password printer problem problems router slow sound startup trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Solved: Java Docs Issues


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
cats31's Avatar
Member with 39 posts.
 
Join Date: Aug 2004
Experience: Intermediate
16-Mar-2008, 04:39 AM #1
Post Solved: Java Docs Issues
Hello again

I've got another java problem for whoever is interested, howvever its alot more complex than the others.

I've been asked to prepare a program that will conduct the following:


Write a program that reads in two String variables from the user and store in variables stringOne and stringTwo respectively. Please note that the input from the user should not be limited to single word strings.
Perform the following operations as listed below, in a given sequence:
• Prompt the user for a specified index and display the character in that position for each string
• Prompt the user for a character to search within the each of the strings and display whether the character exists or not
• Display the number of characters in each string respectively
• Replace both strings with their uppercase equivalent respectively and display both strings
• Concatenate both uppercase strings, store the result in stringOne and display it

For each of the operations listed above, you will need to print the resulting output to screen.

Now, I've put alot of efort and have come up with the following code:

/**
* @(#)stringclass.java
*
* stringclass application
*
* @author
* @version 1.00 2008/3/12
*/

import java.util.*;



public class stringclass {
static Scanner three = new Scanner(System.in);

public static void main(String[] args)
{

// Defines both strings
stringOne Name, Home, Number;

stringTwo Name1, Home1, Number1;

System.out.println("What is your Name?");
Name=three.next();


System.out.println("Where were you born?");
Home=three.next();


//Reads back name to user

System.out.println("Hello "+Name+"welcome.");
Name1=Name.toUppercase();


//Says you were born in
System.out.println("You were born in:"+Home);
Home1=Home.toUppercase;

//Asks for number in worded form

System.out.println("Print a number between 5 & 8 in words:");
Number=three.next();


//Says what is in both Stringone and Stringtwo


//Changes Name, Home and number to Uppercase

System.out.println("Your Name in Uppercase is" +Name1);

System.out.println("Your Birthplace in Uppercase is" +Home1);

System.out.println("The Number you typed in Uppercase is"+Number1);

//Concatenate strings into stringone and display



}
}


As you can see it is incomplete. At the momment I am unable to get the program to read the two strings I have defined at the top. It keeps on coming up with an error saying "Cannot find symbol" I am uncertan if i've forgotten something or done something wrong, because it is near identical to all the other programs I have created so far.

If anyone could help it would be greatly appreciated

Thanks again
Chicon's Avatar
Computer Specs
Distinguished Member with 6,677 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
16-Mar-2008, 09:11 AM #2
There're a few syntax errors in your coding :
the lines :
stringOne Name, Home, Number;

stringTwo Name1, Home1, Number1;


must be replaced by :
String stringOne, Name, Home, Number;

String stringTwo, Name1, Home1, Number1;


For the following lines :
Name1=Name.toUppercase();
Home1=Home.toUppercase;

the right syntax of the method is toUpperCase()

Also, the coding doesn't correspond to the needs of your homework. You made it too complex.
__________________
Never teach an old monkey how to make faces. - (French maxim)
Jackiefrost9's Avatar
Computer Specs
Distinguished Member with 3,796 posts.
 
Join Date: Jun 2004
Location: Spokane, Wa
Experience: Advanced
20-Mar-2008, 12:27 AM #3
Be careful about how you add variables to srtings, something like this:
System.out.println("You were born in:"+Home);
would produce this output for me:
"You were born in:Spokane"
Notice there is no space in between the : and Spokane.
You did the same thing here:
"Hello "+Name+"welcome."
That would produce "Hello Brianwelcome" for me. Just add a space before wlecome.
__________________
M.O.U.S.

I do things with hardware n stuff

I'm at the University of Washington
Computer Engineering
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:18 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.