Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: hmm for some reason the char.At isnt working

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default hmm for some reason the char.At isnt working

    so i did hte code and did exactly what the teacher asked, they had said we needed a char(x,y) but im getting an error, why?

     
    import javax.swing.*;
     
    public class JMaths
    {
    	public static void main(String[] args)
    	{
     
            String Along;
    		String OfWords;
    		Double Agent;
    		Double Entry;
     
    		Along  = JOptionPane.showInputDialog("Give me a number");
    		Agent  = Double.parseDouble(Along) * 1.00;
     
    		Entry = Math.sin ( Math.toRadians(Agent) );
    		JOptionPane.showMessageDialog(null,"Sin of Entry = " + Entry);
    		JOptionPane.showMessageDialog(null,"Cosecant of Entry = " + (1/Entry));
     
    		Entry = Math.cos ( Math.toRadians(Agent) );
    		JOptionPane.showMessageDialog(null,"Cos of Entry = " + Entry);
    		JOptionPane.showMessageDialog(null,"Secant of Entry = " + (1/Entry));
     
    		Entry = Math.tan ( Math.toRadians(Agent) );
    		JOptionPane.showMessageDialog(null,"Tan of Entry = " + Entry);
    		JOptionPane.showMessageDialog(null,"Cotangent of Entry = " + (1/Entry));
     
            Entry = Math.pow(Agent,2);
    		JOptionPane.showMessageDialog(null,"Entry to the second power = " + Entry);
     
    		Entry = Math.sqrt(Agent);
    		JOptionPane.showMessageDialog(null,"The square root of the entry = " + Entry);
     
    		OfWords = JOptionPane.showInputDialog("Give me a sentence");
    		JOptionPane.showMessageDialog(null,"Value at charAt(2) = " + OfWords.charAt(2) );
    		JOptionPane.showMessageDialog(null,"Value at charAt(2,5) = " + OfWords.charAt(2,5) );
    		JOptionPane.showMessageDialog(null,"Value at substring(2) = " + OfWords.substring(1) );
    		JOptionPane.showMessageDialog(null,"Value at substring(2,5) = " + OfWords.substring(1,5) );
    		JOptionPane.showMessageDialog(null,"Value at indexOf('2') = " + OfWords.indexOf('2') );
    		JOptionPane.showMessageDialog(null,"Value at indexOf('2',5) = " + OfWords.indexOf('2',5) );
        }
    }


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: hmm for some reason the char.At isnt working

    What error are you getting?

    Also, the charAt method only takes an int not two ints.

    System.out.println("test".charAt(0));

    // Json

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: hmm for some reason the char.At isnt working

    so then i might have written down what he wanted the wrong way.

    Instead of charAt(x)
    and a charAt(x,y)

    would it make alot more sense if it was asked
    charAt(x)
    charAt(y)

  4. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: hmm for some reason the char.At isnt working

    Probably, yes

    // Json

Similar Threads

  1. Working with MAC .DMG files
    By mdv2000 in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: January 21st, 2010, 12:31 PM
  2. Little Help, Price Reset is not working
    By drkossa in forum AWT / Java Swing
    Replies: 1
    Last Post: January 14th, 2010, 06:00 PM
  3. char (toUppercase?)
    By chronoz13 in forum Java Theory & Questions
    Replies: 4
    Last Post: December 12th, 2009, 10:01 AM
  4. Working with Methods
    By duckman in forum Object Oriented Programming
    Replies: 3
    Last Post: November 9th, 2009, 08:27 PM
  5. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM