Need help with simple loops

Hi I am having a very very difficult time. for thos that have it I'm using the Intro to Java Programming 6th Edition by Y.Daniel Liang Book. I am on page 124 Ch 4 Problem 4.18
what it wants you to do is make and use nested loops that print
Pattern 1
1
12
123
1234
12345
123456
Pattern 2
123456
12345
1234
123
12
1
Patern 3
1
21
321
4321
54321
654321 ( I know this is crooked but you get the idea )
Pattern 4
123456
12345
1234
123
12
1 (once again crooked but you get the idea )
Ok so here is my code thus for and it includes pattern 1 and pattern 2...Keep in mind I'm just simply printing them out one right after the other..it doesnt have to look all pretty or nothing like that ok...thanks
public class Patterns
// Print Pattern I */
public static void main(String[] args)
for (int i = 1; i <= 6; i++)
for (int j = 1; j <= i; j++) ( NESTED FOR STATMENT)
          System.out.print(j + " ");
     System.out.println();
// Print Patter II
     for ( int i = 6 ; i >=1; i--)
          for ( int j = 1; j <= i; j++) (NESTED FOR STATMENT )
               System.out.print ( j + " ") ;
          System.out.println();
If yall could somehow give me hints as to how to get number 3 and number 4 thanks
-tim-

package src;
public class Escada {
    public Escada(){
        System.out.println("Pattern1");
        for (Integer i = 1; i <= 6; i++){
            for (Integer j = 1; j <= i; j++){
                System.out.print(j);
            System.out.println("");
        System.out.println("--------\nPattern2");
        for (Integer i = 6; i >= 1; i--){
            for (Integer j = 1; j <= i; j++){
                System.out.print(j);
            System.out.println("");
        System.out.println("--------\nPattern3");
        for (Integer i = 1; i <= 6; i++){
            for (Integer j = i; j >=1; j--){
                System.out.print(j);
            System.out.println("");
        System.out.println("--------\nPattern4");
        for (Integer i = 6; i >= 1; i--){
            for(Integer j = 1; j <= i; j++){
                System.out.print(j);
            System.out.println("");
    public static void main(String[] args) {
        new Escada();

Similar Messages

  • Need Help With Simple ABAP Code

    Hello,
    I'm loading data from a DSO (ZDTBMAJ) to an Infocube (ZCBRAD06). I need help with ABAP code to some of the logic in Start Routine. DSO has 2 fields: ZOCTDLINX & ZOCBRDMAJ.
    1. Need to populate ZOCPRODCD & ZOCREFNUM fields in Infocube:
        Logic:-
        Lookup /BI0/PMATERIAL, if /BIC/ZOCBRDMAJ = /BIC/OIZOCBRDMAJ
        then /BIC/ZOCPRODCD = ZOCPRODCD in Infocube
               /BIC/ZOCREFNUM = ZOCREFNUM in Infocube         
    2. Need to populate 0G_CWWTER field in Infocube:
        Logic:
        Lookup /BIC/PZOCTDLINX, if /BIC/ZOCTDLINX = BIC/OIZOCTDLINX
        then G_CWWTER = 0G_CWWTER in Infocube.
    I would need to read single row at a time.
    Thanks!

    I resolved it.

  • Need Help with simple array program!

    Hi, I have just recently started how to use arrays[] in Java and I'm a bit confused and need help designing a program.
    What this program does, it reads in a range of letters specified by the user. The user then enters the letters (a, b or c) and stores these characters into an array, which the array's length is equal to the input range the user would enter at the start of the program. The program is then meant to find how many times (a,b and c) appears in the array and the Index it first appears at, then prints these results.
    Here is my Code for the program, hopefully this would make sense of what my program is suppose to do.
    import B102.*;
    class Letters
         static int GetSize()
              int size = 0;
              boolean err = true;
              while(err == true)
                   Screen.out.println("How Many Letters would you like to read in?");
                   size = Keybd.in.readInt();
                   err = Keybd.in.fail();
                   Keybd.in.clearError();
                   if(size <= 0)
                        err = true;
                        Screen.out.println("Invalid Input");
              return(size);
         static char[] ReadInput(int size)
              char input;
              char[] letter = new char[size];
              for(int start = 1; start <= size; start++)
                   System.out.println("Please enter a letter (a, b or c) ("+size+" max), enter # to stop:");
                   input = Keybd.in.readChar();
                   while((input != 'a') && (input != 'b') && (input != 'c') && (input != '#'))
                        Screen.out.println("Invalid Input");
                        System.out.println("Please enter a letter (a, b or c) ("+size+" max, enter # to stop:");
                        input = Keybd.in.readChar();
                                    while(input == '#')
                                                 start == size;
                                                 break;
                   for(int i = 0; i < letter.length; i++)
                        letter[i] = input;
              return(letter);
         static int CountA(char[] letter)
              int acount = 0;
              for(int i = 0; i < letter.length; i++)
                   if(letter[i] == 'a')
                        acount++;
              return(acount);
         static int CountB(char[] letter)
              int bcount = 0;
              for(int i = 0; i < letter.length; i++)
                   if(letter[i] == 'b')
                        bcount++;
              return(bcount);
         static int CountC(char[] letter)
              int ccount = 0;
              for(int i = 0; i < letter.length; i++)
                   if(letter[i] == 'c')
                        ccount++;
              return(ccount);
         static int SearchA(char[] letter)
              int ia;
              for(ia = 0; ia < letter.length; ia++)
                   if(letter[ia] == 'a')
                        return(ia);
              return(ia);
         static int SearchB(char[] letter)
              int ib;
              for(ib = 0; ib < letter.length; ib++)
                   if(letter[ib] == 'b')
                        return(ib);
              return(ib);
         static int SearchC(char[] letter)
              int ic;
              for(ic = 0; ic < letter.length; ic++)
                   if(letter[ic] == 'c')
                        return(ic);
              return(ic);
         static void PrintResult(char[] letter, int acount, int bcount, int ccount, int ia, int ib, int ic)
              if(ia <= 1)
                   System.out.println("There are "+acount+" a's found, first appearing at index "+ia);
              else
                   System.out.println("There are no a's found");
              if(ib <= 1)
                   System.out.println("There are "+bcount+" b's found, first appearing at index "+ib);
              else
                   System.out.println("There are no b's found");
              if(ic <= 1)
                   System.out.println("There are "+ccount+" c's found, first appearing at index "+ic);
              else
                   System.out.println("There are no c's found");
              return;
         public static void main(String args[])
              int size;
              char[] letter;
              int acount;
              int bcount;
              int ccount;
              int ia;
              int ib;
              int ic;
              size = GetSize();
              letter = ReadInput(size);
              acount = CountA(letter);
              bcount = CountB(letter);
              ccount = CountC(letter);
              ia = SearchA(letter);
              ib = SearchB(letter);
              ic = SearchC(letter);
              PrintResult(letter, acount, bcount, ccount, ia, ib, ic);
              return;
    }     Some errors i get with my program are:
    When reading in the letters to store into the array, I get the last letter I entered placed into the entire array. Also I believe my code to find the Index is incorrect.
    Example Testing: How many letters would you like to read? 3
    Enter letter (a, b or c) (# to quit): a
    Enter letter (a, b or c) (# to quit): b
    Enter letter (a, b or c) (# to quit): c
    It prints "There are no a's'" (there should be 1 a at index 0)
    "There are no b's" (there should be 1 b at index 1)
    and "There are 3 c's, first appearing at index 0" ( there should be 1 c at index 2)
    The last thing is that my code for when the user enters "#" that the input of letters would stop and the program would then continue over to the counting and searching part for the letters, my I believe is correct but I get the same problem as stated above where the program takes the character "#" and stores it into the entire array.
    Example Testing:How many letters would you like to read? 3
    Enter letter (a, b or c) (# to quit): a
    Enter letter (a, b or c) (# to quit): #
    It prints "There are no a's'" (should have been 1 a at index 0)
    "There are no b's"
    and "There are no c's"
    Can someone please help me??? or does anyone have a program simular to this they have done and would'nt mind showing me how it works?
    Thanks
    lou87.

    Without thinking too much...something like this
    for(int start = 0; start < size; start++) {
                System.out.println("Please enter a letter (a, b or c) ("+size+" max), enter # to stop:");
                input = Keybd.in.readChar();
                while((input != 'a') && (input != 'b') && (input != 'c') && (input != '#')) {
                    Screen.out.println("Invalid Input");
                    System.out.println("Please enter a letter (a, b or c) ("+size+" max, enter # to stop:");
                    input = Keybd.in.readChar();
                if(input == '#') {
                        break;
                letter[start] = input;
            }you dont even need to do start = size; coz with the break you go out of the for loop.

  • Need help with simple XML validation

    I am new to Spry and need some help creating a simple
    validation. There is a form field which must not contain a value
    already in the database. I have a script which accepts a parameter
    and returns a boolean result. Here is the XML:
    <samples>
    <sample>
    <ISFOUND>0</ISFOUND>
    </sample>
    </samples>
    1. How do I call this script when the form field changes and
    pass the form value as the parameter?
    2. How do I check the returned value in the XML and throw an
    error if true?
    I appreciate any help with this. Please let me know if there
    is a better way to achieve the same result.
    Thanks,
    Rich

    I enabled the call to the XML response. However, I am having
    trouble identifying when the call is complete so I can parse the
    result. How do I run my check after the data load and display the
    proper message?

  • Beginner needs help with simple code.

    I just statrted learnind java, and I need some help with this simple program. For some reason everytime I enter my Farenheit value, the Celsius conversion returns as 0.0. Would really appreciate the help. Thanks.
    Here's the code:
    public class TempConverter
    public static void main(String[] args)
    double F = Double.parseDouble(args[0]);
    System.out.println("Temperature in Farenheit is: " + F);
    double C = 5 / 9;
    C *= (F - 32);
    System.out.println("Temperature in Celsius is: " + C);
    }

    double C = 5 / 9This considers "5" and "9" to be integers and does an integer division, discarding the remainder. The result of that division is 0. Trydouble C = 5.0/9.0;

  • I need help with a loop within an hour

    I need to make a loop that gives 100, 10, 1000, 100, 10000, 1000...
    I can use a for loop, if loop, while loop, and do while loop.
    Thanks

    warnerja wrote:
    sharkura wrote:
    warnerja wrote:
    sharkura wrote:
    Sorry warnerja. I know I should have done the same. I just couldn't help myself. I need to keep telling rubbish.
    :D
    ¦ {ÞIt's not too late to edit your spoon-fed solution, though the OP may have seen and copied it by now.And you know this isn't going to make the OP a programmer, unless he/she/it changes his/her/its stripes.
    ¦ {ÞYes, but its laziness will continue to be encouraged more than it should.Nah. It'll crash and burn on the next assignment.
    ¦ {Þ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • I need help with simple problems. im a student.

    i'd like to be advanced with my studies so i will post questions.. i need help on how to answer. thank you.
    1. create a java program that will evaluate if the value entered is a positive, negative, vowel, consonant and special characters.
    im actually done with the positive and negative using if else statements.. i used an integer data type. now my question is how do conjoin the characters when i need to evaluate a vowel and a consonant. i cant use char either. please help. i dont know what to do yet.
    2. create java program that will translate the input from numbers to words. e.g. input:123 output: one hundred twenty-three.
    i have an idea to use a switch case statement. but i have no idea on how will i be able to do it. so if you guys can help me.. well then thankies..

    Welcome to the Sun forums. First, please note that you have posted in the wrong forum. This forum is for topics related to Sun's JavaHelp product. You should post your questions in the New to Java forum.
    As part of your learning, you will have to develop the ability to select an approach to a problem, create a design that reflects that approach, and then implement the design with code that you create.
    So, it's inappropriate for us to take the problem statement that you have been given and short-circuit your learning process by giving you the implemented problem solution. We can comment on the individual questions that you may have, and point out problems and errors that we see in the code that you develop.
    As a hint, when you are stuck, forget about Java and programming. Just start with a sheet of paper and a pencil, and figure out how to layout the task on paper. The consider how to translate that to programming.
    If you have problems, post short example code that shows the problem, and explain your question clearly. We can't read minds.
    Make sure you post code correctly so that it's not mangled by the forum software, and so that formatting is maintained. Select your typed or pasted code block and press the CODE button above the typing area.

  • Need help with while loop format

    I'm building a form - everything works but I would like to change the way the data is output into the table.
    In other scripting languages, like PHP, you had 2 different ways of dealing with a loop:
    <?
    do while xyz
    do something here
    ?>
    - OR -
    <? do while xyz:?>
    do something here
    <?end while ?>
    I would like to do something similar to the 2nd example in .jsp but I'm not sure of the format or how to stop the loop. From the tutorial, I'm using
    <%
    while(SQLResult.next())
    UId = SQLResult.getString("uid");
    FName = SQLResult.getString("fname");
    LName = SQLResult.getString("lname");
    out.println("<tr><td>" + UId + "</td><td>" + FName + "</td><td>" + LName
    + "</td></tr>");
    %>
    Could anyone point me in the right direction? I'd prefer it if I didn't have to build the table like this if I don't have to but haven't found anything anywhere telling me otherwise.
    Thanks so much.
    Bob

    Sorry - the answer was in JSP:Java Server Pages by Barry Burd. I had just gotten the output format wrong.

  • Need help with simple file sharing application

    I have an assignment to build a Java File Sharing application. Since I'm relatively new to programming, this is not gonna be an easy task for me.
    Therefore I was wondering if there are people willing to help me in the next few days. I will ask questions in this thread, there will be loads of them.
    I already have something done but I'm not nearly halfway finished.
    Is there a code example of a simple file sharing application somewhere? I didn't manage to find it.
    More-less, this is what it needs to contain:
    -client/server communication (almost over)
    -file sending (upload, download)
    -file search function (almost over)
    -GUI of an application.
    GUI is something I will do at the end, hopefully.
    I hope someone will help me. Cheers
    One more thing, I'm not asking for anyone to do my homework. I will only be needing some help in the various steps of building an application.
    As I said code examples are most welcome.
    This is what I have done so far
    Server:
    package ToJeTo;
    import java.io.*;
    import java.net.*;
    public class MultiServer {
        public static ServerSocket serverskiSoket;
        public static int PORT = 1233;
        public static void main(String[] args) throws IOException {
            try {
                serverskiSoket = new ServerSocket(PORT);
            }catch (IOException e) {
                System.out.println("Connection impossible");
                System.exit(1);
            do {
                Socket client = serverskiSoket.accept();
                System.out.println("accepted");
                ClientHandler handler = new ClientHandler(client);
                handler.start();
            } while(true);
    }Client:
    package ToJeTo;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.net.*;
    import java.util.Scanner;
    public class MultiClient {
        public static InetAddress host;
        public static int PORT = 1233;
        public static void main(String[] args) {
            try {
                host = InetAddress.getLocalHost();
            }catch (UnknownHostException uhe) {
                System.out.println("Error!");
                System.exit(1);
            sendMessages();
        private static void sendMessages() {
            Socket soket = null;
            try {
                soket = new Socket(host, PORT);
                Scanner networkInput = new Scanner(soket.getInputStream());
                PrintWriter networkOutput = new PrintWriter(soket.getOutputStream(), true);
                Scanner unos = new Scanner(System.in);
                String message, response;
                do {
                    System.out.println("Enter message");
                    message = unos.nextLine();
                    networkOutput.println(message);
                    response = networkInput.nextLine();
                    System.out.println("Server: " + response);
                }while (!message.equals("QUIT"));
            } catch (IOException e) {
                e.printStackTrace();
            finally {
                try{
                    System.out.println("Closing..");
                    soket.close();
                } catch (IOException e) {
                    System.out.println("Impossible to disconnect!");
                    System.exit(1);
    }ClientHandler:
    package ToJeTo;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class ClientHandler extends Thread {
        private Socket client;
        private Scanner input;
        private PrintWriter output;
        public ClientHandler(Socket serverskiSoket) {
            client = serverskiSoket;
            try {
            input = new Scanner(client.getInputStream());
            output = new PrintWriter(client.getOutputStream(), true);
            } catch (IOException e) {
                e.printStackTrace();
            public void run() {
                String received;
                do {
                received = input.nextLine();
                output.println("Reply: " + received);
                } while (!received.equals("QUIT"));
                try {
                    if (client != null)
                        System.out.println("Closing the connection...");
                        client.close();
                }catch (IOException e) {
                    System.out.println("Error!");
    }Those three classes are simple client server multi-threaded connection.

    Now the other part that contains the search function looks like this:
    package ToJeTo;
    import java.io.*;
    import java.util.*;
    public class User {
        String nickname;
        String ipAddress;
        static ArrayList<String> listOfFiles = new ArrayList<String>();
        File sharedFolder;
        String fileLocation;
        public User(String nickname, String ipAddress, String fileLocation) {
            this.nickname = nickname.toLowerCase();
            this.ipAddress = ipAddress;
            sharedFolder = new File(fileLocation);
            File[] files = sharedFolder.listFiles();
            for (int i = 0; i < files.length; i++) {
                listOfFiles.add(i, files.toString().substring(fileLocation.length()+1));
    public static void showTheList() {
    for (int i = 0; i < listOfFiles.size(); i++) {
    System.out.println(listOfFiles.get(i).toString());
    @Override
    public String toString() {
    return nickname + " " + ipAddress;
    User Manager:
    package ToJeTo;
    import java.io.*;
    import java.util.*;
    class UserManager {
        static ArrayList<User> allTheUsers = new ArrayList<User>();;
        public static void addUser(User newUser) {
            allTheUsers.add(newUser);
        public static void showAndStoreTheListOfUsers() throws FileNotFoundException, IOException {
            BufferedWriter out = new BufferedWriter(new FileWriter("List Of Users.txt"));
            for (int i = 0; i < allTheUsers.size(); i++) {
                    System.out.println(allTheUsers.get(i));
                    out.write(allTheUsers.get(i).toString());
                    out.newLine();
            out.close();
    }Request For File
    package ToJeTo;
    import java.util.*;
    public class RequestForFile {
        static ArrayList<String> listOfUsersWithFile = new ArrayList<String>();
        Scanner input;
        String fileName;
        public RequestForFile() {
            System.out.println("Type the wanted filename here: ");
            input = new Scanner(System.in);
            fileName = input.nextLine();
            for (User u : UserManager.allTheUsers) {
                for (String str : User.listOfFiles) {
                    if (str.equalsIgnoreCase(fileName))
                        listOfUsersWithFile.add(u.nickname);
        public RequestForFile(String fileName) {
            for (User u : UserManager.allTheUsers) {
                for (String str : User.listOfFiles) {
                    if (str.equalsIgnoreCase(fileName))
                        listOfUsersWithFile.add(u.nickname);
        public static List<String> getAll() {
            for (int i = 0; i < listOfUsersWithFile.size(); i++) {
                //System.out.println("User that has the file: " + listOfUsersWithFile.get(i));
            return listOfUsersWithFile;
    }Now this is the general idea.
    The user logs in with his nickname and ip address. He defines his own shared folder and makes it available for other users that log on to server.
    Now each user has their own list of files from a shared folder. It's an ArrayList.
    User manager class is there to store another list, a list of users that are connected with server.
    When the user is searching for a particular file, he is searching through all the users and their respective files lists. Therefore for each loop inside a for each loop.
    Now the problem is how to connect all that with Client and Server class and put it into one piece.
    GUI should look somewhat like this:

  • Need Help with Simple Chat Program

    Hello Guys,
    I'm fairly new to Java and I have a quick question regarding a simple chat program in java. My problem is that I have a simple chat program that runs from its own JFrame etc. Most of you are probably familiar with the code below, i got it from one of my java books. In any case, what I'm attempting to do is integrate this chat pane into a gui that i have created. I attempted to call an instace of the Client class from my gui program so that I can use the textfield and textarea contained in my app, but it will not allow me to do it. Would I need to integrate this code into the code for my Gui class. I have a simple program that contains chat and a game. The code for the Client is listed below.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    public class Client
    extends JPanel {
    public static void main(String[] args) throws IOException {
    String name = args[0];
    String host = args[1];
    int port = Integer.parseInt(args[2]);
    final Socket s = new Socket(host, port);
    final Client c = new Client(name, s);
    JFrame f = new JFrame("Client : " + name);
    f.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
    c.shutDown();
    System.exit(0);
    f.setSize(300, 300);
    f.setLocation(100, 100);
    f.setContentPane(c);
    f.setVisible(true);
    private String mName;
    private JTextArea mOutputArea;
    private JTextField mInputField;
    private PrintWriter mOut;
    public Client(final String name, Socket s)
    throws IOException {
    mName = name;
    createUI();
    wireNetwork(s);
    wireEvents();
    public void shutDown() {
    mOut.println("");
    mOut.close();
    protected void createUI() {
    setLayout(new BorderLayout());
    mOutputArea = new JTextArea();
    mOutputArea.setLineWrap(true);
    mOutputArea.setEditable(false);
    add(new JScrollPane(mOutputArea), BorderLayout.CENTER);
    mInputField = new JTextField(20);
    JPanel controls = new JPanel();
    controls.add(mInputField);
    add(controls, BorderLayout.SOUTH);
    mInputField.requestFocus();
    protected void wireNetwork(Socket s) throws IOException {
    mOut = new PrintWriter(s.getOutputStream(), true);
    final String eol = System.getProperty("line.separator");
    new Listener(s.getInputStream()) {
    public void processLine(String line) {
    mOutputArea.append(line + eol);
    mOutputArea.setCaretPosition(
    mOutputArea.getDocument().getLength());
    protected void wireEvents() {
    mInputField.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    String line = mInputField.getText();
    if (line.length() == 0) return;
    mOut.println(mName + " : " + line);
    mInputField.setText("");

    Thanks for ur help!i have moved BufferedReader outside the loop. I dont think i am getting exception as i can c the output once.What i am trying to do is repeat the process which i m getting once.What my method does is first one sends the packet to multicasting group (UDP) and other method receives the packets and prints.

  • Need help with the loop

    I'm a beginner. I'm trying to get this output
    Initial number of stars:
    7
    Here's my program. What's wrong with it? Please help
    import java.io.*;
    class starWedge
    public static void main (String[] args ) throws IOException
    int numStars; // the number of stars
    int row ; // current row number
    int star; // the number of stars in this row so far
    BufferedReader userin = new BufferedReader (new InputStreamReader(System.in));
    String inputData;
    // collect input data from user
    System.out.println( "Initial number of stars:" );
    inputData = userin.readLine();
    numStars = Integer.parseInt( inputData );
    row = 1;
    while ( row <= numStars )
    star = 1;
    star = numStars - star;
    System.out.print("*");
    star = star + 1;
    System.out.println(); // end each line
    row = row + 1;

    Okay the one thing that I see immediately is that your while loop never actully exits. Not once. Why? Well simple your exit condition is the row <= numStars, yet nither numStars nor row actually change their values within the loop. In short row always equals 1 and thus never is equal to greater than numStars and the while loop does not terminate.
    Second thing is that your star drawing logic is not correct. Meaning you have not told to draw the specific number of stars in one given line. For starters the System.out.println() command should be in the loop not outside it. For your purposes a for-loop nested within a while-loop is much better.
    If you think you know what's wrong your program than read no further and go try it on your own. But if you still have no clue below is my modification of your code that actually produces the pattern you want, it might provide you with more hints.
    import java.io.*;
    class starWedge{
    public static void main (String[] args ) throws IOException{
         int numStars; // the number of stars
         int row ; // current row number
         int star; // the number of stars in this row so far
         BufferedReader userin = new BufferedReader (new InputStreamReader(System.in));
         String inputData;
         // collect input data from user
         System.out.println( "Initial number of stars:" );
         inputData = userin.readLine();
         numStars = Integer.parseInt( inputData );
         row = 1;
         while (numStars > 0){
         for(star = 1; star<=numStars; star++){
              System.out.print("*");
         numStars = numStars - 1;
         System.out.println(); // end each line
    }

  • Need help with simple problem.......

    Hello, I'm fairly new to Java, taking my first year in it. I have a little applet that I have to write up but I'm having some difficulties. Someone please help :)
    OBJECTIVE: Print out the following using a FOR loop.
    OUTPUT:
    JavaProgramming
    JavaProgramming
    JavaProgramming
    JavaProgramming
    JavaProgramming
    I am really having trouble doing the loop and spacing, so that it would have "JavaProgramming" appear 5 times and automatically indent 2 spaces everytime. I've done a "HSA" Console Program (NOT APPLET) where there are 5 words that are not spaced but when I try to do the same in an applet, it simply wont repeat in the loop. Below is the program where there are 5 words WITHOUT spacing in my applet program, I don't know how to repeat it 5 times and have it space 2 times everytime :(
    public class Test extends Applet
        // Place instance variables here
        public void init ()
        } // init method
        public void paint (Graphics g)
            for (int i = 0 ; i < 5 ; i++)
                g.drawString ("JavaProgramming", 20, 20);
        } // paint method
    } // Test classThis will only show "JavaProgramming" once when i run the program. I need it to show 5 times, with 2 spaces indented every time!

    this:
    g.drawString ("JavaProgramming", 20, 20);
    probably needs to be something like:
    g.drawString("JavaProgramming", 20+(i*10), 20+(i*10));
    i.e: increase x and y pos for each iteration.

  • Need help with while loop and shift registers

    I have a large data set and need to read in the data at maybe 200 samples at a time, process these samples through my VI, and have it append and concatenate a separate lvm file.  The part where I am confused is the shift registers. How do I limit the number of samples read in an iteration? How do I get the while loop to stop when all the data are read in?
    I've attached my diagram, maybe there is something wrong with my technique?
    Solved!
    Go to Solution.
    Attachments:
    shiftreg.JPG ‏56 KB

    This will give you an idea.  There are plenty of other (probably more efficient) methods.  This is a basic, quick and dirty solution to help you grasp the overall concept.
    Using LabVIEW: 7.1.1, 8.5.1 & 2013
    Attachments:
    ShiftRegLoop.JPG ‏54 KB

  • Need help with infinite loop in recovery mode in Creative Zen 20

    hi,
    I'm having this problem with my Creative Zen 20 GB:
    When I turned it on, it goes immediately to the rescue/recovery mode. Not sure why. Will do that even when I reset the device.
    So, I selected cleanup. After cleanup, it remained showing the menu of the recovery mode. I selected reboot. After reboot, it went back to the rescue/recovery mode. And it goes on and on like an infinite loop.
    Finally, I decided to do a formatAll. Again, it remained in the recovery mode menu after the formatAll action. After reboot, it again went back to the rescue/recovery mode.
    I have never updated the firmware. So, I thought maybe that will help. However, when I connected the device to my PC, the device went to rescue/recovery mode and the PC could not detect the device connected via USB. In short, I am currently not able to do anything at all with the device except charging it.
    Would appreciate help/advise.
    Tks in advance.

    huggiebear wrote:
    I connected the device to the PC and after the PC tried to load the library, it said "Player is not connected".
    What library are you loading? After you have run that reload os option, you need to connect the player to the computer and run the firmware update software. If you haven't download that, you can go to the download section and download it. If all else fail, the player is probably faulty and you would need to get in contact with Customer Support then.
    Jason

  • URL: newbie needs help with simple programming question!

    Hi everyone,
    Please direct me to a FAQ or other resource, or help me with this problem:
    I want to create a text field (or similar container) that contains both ordinary text AND a URL/hyperlink in it. For example, the following text might appear in the text field:
    "I have many _pictures_ from my vacation"
    where the word "pictures" is actually a hyperlink to a web site, and the other portions of the string are simple text.
    All advice and help is appreciated!
    -Dennis Reda
    [email protected]

    Well here is one way you code do it but if you do alittle research on them links above it will explain how this code works.Well it will explain how jeditorpane and hyperlinklistener work
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    import java.net.*;
    public class b extends javax.swing.JApplet implements HyperlinkListener  {
       JEditorPane field = new JEditorPane();
      public b() {
        Container pane = getContentPane();
        FlowLayout flo = new FlowLayout();
        pane.setLayout(flo);
        field.setPreferredSize(new Dimension(200, 25));
        field.setEditable(false);
        pane.add(field);
        setContentPane(pane);
         String gg1 = "<html><body>I have many_<a    href='http://www.home.com'>pictures</a>_from my vacation</body></html>";
         field.addHyperlinkListener(this);
         field.setContentType("text/html");
         field.setText(gg1);
      public void hyperlinkUpdate(HyperlinkEvent e) {
         if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
          try{
            URL url = new URL("http://www.msn.com");
            getAppletContext().showDocument(url,"_self"); 
            }catch(Exception r) {};
      public void init()  {
         b c = new b();
    ps hope this helped                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for