Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    New to the CF scene
    Join Date
    Nov 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Noob question, hope you can help

    For my intro to java class I have to write a simple prog that does this

    Part1: (5 marks)
    Write an application to produce the following pattern. Use 2 nested for statements. to display one single character inside inner loop.


    AAAA
    BBB
    CC
    D
    Hint: character variables are represented as numbers, arithmetic operations can be performed on characters.

    Ex.
    char var = 'a'; //var holds a
    var ++; //var holds b
    ____________________________________________________________
    and heres what I've got, but its not displaying anything for me:

    /*
    * Author: Casey Bolton
    * Date: 10/26/04
    * Purpose:
    */
    import java.applet.Applet;
    import java.awt.*;
    //import java.io.*;
    public class Lab6Char extends Applet{

    public void paint(Graphics g){
    int y =10;
    int q = 4;

    for(char v= 'a'; v <='d';v++){
    int x=5;

    for(int t=1; t>=q; t++){
    g.drawString(""+v,x,y);
    x=x+10;
    }
    }
    q=q-1;
    y=y+10;
    }
    }
    dizzynights.com An Australian backpacking site

    Looking for a php coder to split revenue with on a new project pm me for more details

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You've got the wrong forum, this is javascript, ask a mod to move it to the computer programming forum

  • #3
    New to the CF scene
    Join Date
    Nov 2004
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What do you mean? This is written in java?
    dizzynights.com An Australian backpacking site

    Looking for a php coder to split revenue with on a new project pm me for more details

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Java is the programming language you are doing. This is the Javascript forum, it's a scripting language. Two totally different things

  • #5
    New Coder
    Join Date
    Nov 2004
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The code below will give you the looping and character changing.
    You'll have to adapt it to run in an applet, which won't take much, but I can't do the whole thing for you. Good luck.

    Code:
    int q = 4;
            int t = 4;
            
            char c = 'A';
    
            for(int i = 0; i < t; i++){
                for(int v = 0; v < q; v++){
                    System.out.print("" + c);
                }
                System.out.println();
                c++;
                q--;
            }

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Quote Originally Posted by turbowrx
    The code below will give you the looping and character changing.
    You'll have to adapt it to run in an applet, which won't take much, but I can't do the whole thing for you. Good luck.

    Code:
    int q = 4;
            int t = 4;
            
            char c = 'A';
    
            for(int i = 0; i < t; i++){
                for(int v = 0; v < q; v++){
                    System.out.print("" + c);
                }
                System.out.println();
                c++;
                q--;
            }

    I hope you get a good grade on his homework assignment. It is against our ethics here at CodingForums to do other people's homework assignments. That is called cheating. Please do not do that again. You might think you are helping but you really aren't. The point of a homework assignment is for that student to learn. By doing it for them all they learned is how to cheat on future assignments.
    Last edited by Spookster; 11-18-2004 at 01:26 AM.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    New Coder
    Join Date
    Nov 2004
    Location
    wisconsin
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    huh????

    Quote Originally Posted by Spookster
    Originally Posted by Spookster
    I hope you get a good grade on his homework assignment. It is against our ethics here at CodingForums not to do other people's homework assignments. That is called cheating. Please do not do that again. You might think you are helping but you really aren't. The point of a homework assignment is for that student to learn. By doing it for them all they learned is how to cheat on future assignments.
    why r u mad. you said it was good to do other peoples assigs!?!
    Last edited by Antoniohawk; 11-18-2004 at 12:51 AM.

  • #8
    Regular Coder
    Join Date
    Sep 2002
    Location
    Calgary, AB
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, he is saying that by doing another users homework assignment, you are aiding in his cheating. Homework is meant for students to learn the required necessities of the subject, and by not doing them, they are only hindering themselves.

  • #9
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Ragol and Spookster are both right. I'm wondering jettlarue2003, did you join the forums just to point out Spookster's typo, as this is your first post?

  • #10
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    Quote Originally Posted by jettlarue2003
    why r u mad. you said it was good to do other peoples assigs!?!
    ='D thanks man, i needed that

    making fun of people is fun (plz dont make fun of me *puppy dog eyes*


    anyway, i dont really see how someone could answer this without doing it for him, and its pretty simple (if i could do it it must be)

    edit: although you could have done it only usnig 3 variables like this:
    Code:
    char c = 'A';
    for(int i=4; i>0; i--)
    {
    	for(int j=0; j<i; j++)
    	{
    		System.out.print(c);
    	}
    	System.out.println();
    	c++;
    }
    you could even have used c instead of i (as long as you incremented and subtracted to get the char value to 1 for A (im guessing its 65, so just subtract 64, and where it prints c you print the inverse of it, so althoguh c would be D you could just subtract for it to be A)


    anyway, theres a lil uselessnes for ya
    Last edited by ghell; 11-21-2004 at 03:13 PM.

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    paris, france
    Posts
    1,216
    Thanks
    0
    Thanked 0 Times in 0 Posts
    there are 2 fundemental problems with this thread

    1) 4 posts dedicated to subject of homework when poster should have read homework policy

    2) 3 posts of confusion between javascript and java........ when poster should have been using C++

    sorry, just had to have a crack at java
    photoshop too expensive? use the GIMP! www.gimp.org

  • #12
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    Quote Originally Posted by whackaxe
    there are 2 fundemental problems with this thread

    1) 4 posts dedicated to subject of homework when poster should have read homework policy

    2) 3 posts of confusion between javascript and java........ when poster should have been using C++

    sorry, just had to have a crack at java
    and one useless post about how useless half of these posts are

  • #13
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ghell
    and one useless post about how useless half of these posts are
    Make that three.

    shmoove

  • #14
    New to the CF scene
    Join Date
    Nov 2004
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Homework assignment

    Quote Originally Posted by Cptn CrlyBrace
    [SIZE=5]I HAVE THIS HOMEWORK ASSIGNMENT???[/SIZE]
    Just tryn to break the ice... You are right? The teacher I had for this said he would point us in the right direction// maybe our notes or to the book.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •