If you read the Prologue section of the code I posted it will give you an explanation of what I am trying to accomplish with this program.

The problem I am having is that I am unable to find an example of how to pass an argument through the string class using charAt(). what i am looking to do is for every index value of the string Name that is > 0 i want to pass the command toLowercase() but my method is obviously wrong. Below is the debugging tool output

C:\Users\peter\Desktop\CSC 111\welch_lab3\Welch_lab3.java:44: illegal start of expression
Index2 = Name.charAt(>0).toLowerCase(); // puts all char after index value 0 to lowercase
^
1 error

Tool completed with exit code 1

//Prologue Section
/**********************************************************************
 *Program Name:   CSC 111 Lab03
 *Author:    Peter Welch
 *Date:     2/14
 *Course/Section:  CSC 111-001 (002w)
 *Program Description:  This program is designed to Convert a STRING from one format to another and display the converted format.
 *
 *Initial Algorithm:
 *
 *BEGIN Lab03
 *   Begin While loop
 *      Input name
 *      Alter String
 *      Display altered string
 *   End loop when sentinel is entered
 *
 *END Lab03
 *********************************************************************/

 //Pre-Processor Declaration Section

 public class Welch_lab3 // begin class definition
 {

	 public static void main (String[] args) // begin Alter String method
	 {

		int Sentinel = -1; // Value at witch entered exits loop
		int Index1; // finds char at index value 0
		int Index2; //
        String Name; // Name to be converted
        String Index1, Index2, Final_Name;

        // Begin While loop
        while (Name != Sentinel)
        {
			System.out.println ("Enter Name:"); // prompt for input

			String Name = Keyboard.readString (); // stores name to be altered

			Index1 = Name.charAt(0).toUpperCase(); // finds char value at index value 0 and makes it uppercase

			Index2 = Name.charAt(>0).toLowerCase(); // puts all char after index value 0 to lowercase

			Final_Name = Index1 + Index2; // string concatenation

			System.out.println ("Altered string is: " + Final_Name);

		} // end while loop

	} // end method

} // end program

I do not understand why somebody like you Poopster01 with 5 previous posts decide to make a post as CODE SNIPPET instead of FORUM THREAD? What you been trying to achieve?
Thread edited, now it is FORUM THREAD.

As for your error, you are assigning character at position, if you remove ">" before numeric value, which is illegal, from string Name to integer Index2. However even after removal of that typo there it wouldn't work since you are forcing character into integer.

Edited 5 Years Ago by peter_budo: n/a

it wouldn't work since you are forcing character into integer.

Are you sure? char is a 16 bit integer, int is a 32 bit integer - assignment should be legal?

I guess I should keep quite today. To much paracetamol with lemon and honey tea :zzz:
Yes you correct, and lets put it simpler conversion is as char num = Character.toLowerCase(name.charAt(0));

I do not understand your whole coding. How can it possibly work?

1. You have multiple declarations of the same varaibles, but with different types.
i.e. int index1, int index2, String index1, String index2

2. You are trying to compare a String to an int. Which is not possible. while(Name!=Sentinel)
3. Inside the loop, you then re-declare String Name.
4. The original error which was explained.

Edited 5 Years Ago by Akill10: n/a

This article has been dead for over six months. Start a new discussion instead.