What's new

Java Programming - Can anyone help me?

Hello! So I am currently taking intro to java class as a requirement and I do not understand it when it comes to writing the programs. I get good grades on my tests though cus its just multiple choice but when it comes to writing my program assignments i am lost.

I need help with writing the programs because i am completely lost and i only understand some of them. I will give the person who helps me a $20.00 gift card to psn or xbox live store to do my assignments for me. About 10 more are remaining.

Its not cheating I just have other classes that really matter to my major and take up a lot of time.

Here are two assignments i need,

1st assignment
-Write an Applet that is a random number of colored graphics objects – you may choose lines, circles, etc, or a mix of these objects.
You will need to use the Java Random object.

Second assignment
-1. Given that the integer array y has the following elements : [1 2 3], what is the contents of integer array x after executing the following statements :
for (int i = 0; i < 3; i++)
x = y[2-i];
Answer = ____________________________________
2. Write a function that finds the length of a vector.
double Length( double X[ ] )
The length of a vector is the square root of the sum of the squares of the elements in the array. Use dynamic memory and allocate 10 elements for X. Initialize the data values of X to the counting numbers 1-10.
3. Write a function called Average( ) that takes as a parameter a one dimensional array of doubles called A.
Double Average( double A[ ] )
The function computes and returns the average value of the elements in the array (the sum of the elements in the array divided by the number of elements). Use dynamic memory and allocate 10 elements for A. Initialize the data values of A to the counting numbers 1-10.
4. Write a complete program which does the following:
a. Declares an array which holds 4 character strings.
b. Use a for loop and read in 4 character strings and place them in the array.
c. Use a separate for loop to print out the character strings.

If anyone is interested let me know
 
4/4
10/10

thats 62 points for semester. 65 is A and 8/8 20/20 left. I'm honestly done with this shit. All its good for is showing you code. You take an game programming course and the language is different. I'd rather focus on that. In reality, all its doing is confusing me.

EDIT - its still bs about losing the point for the print/println
 
For my game arch class, we had to do a similar thing, but instead, we had to take whatever was in our pockets and make a game out of it. We called it speedball (no we didnt have loads of meth in our pockets). Was basically a coin game with obstacles (candy wrappers) and a goal post (2 coins). It was actually pretty fun. I had this professor before last spring. Hes a great guy, but yea, theres some dude in our class whos always trying to tell him how to run his class. Its fucked up because hes a great professor. Only thing is this is the first time he ever taught these courses, and isnt exactly a gamer. Anyway.

The whole 2d game programming class has been nuts. They are the only exams ive done poorly on, but he curved them so much that it does not even matter. My 67s get curved to 90s lol. Like i said, hes a good guy, but he really doesnt know how to relate the information at a level for people to understand, unless youre that dude or 2 whos telling how to run his class.

Even for java, the exams ive gotten all A's on. It was just the homework that drove me nuts. Anyway, we will knock out these next debugs and call it a day most likely. Thanks for all your help SN. Good luck these next few weeks in your classes.
 
took the 3rd exam yesterday and got an 80 on it.

All i need at this point to get an "A" for the class is a 65% or higher on the next exam.

I got a few more debugs to do this week. Revolves around working with characters/character strings, so it should not be a problem.

I'll post them up tomorrow. Just wanted to let you know about the "A" for the class. Thanks again for all your help Scheisse.
 
Yea, good luck to you too. Just pass. You have the right mentality. I know youll be striving for as high as possible, but just be happy with the pass. All you can do.

Thats crazy about the variables. Im using Game Maker in the game art and design class. I cant seem to use too many variable names in that XD. My game is nice. Its good because im a tester :)
 
Knowing you, you probably got a B :)

Yea i cant wait to show it to you when its done. I went in there Monday and actually game-tested it. It was really a key moment in my life. Game testing my first ever game. And i realized that if i can be a tester, then the things i can test for i can improve and make one hell of a game.

Game Maker is awful, but i went through those first few chapters of java on my own through trial and error (just like game testing...you have to have the patience for it) and also figured out Game Maker on my own. The tutorials give you the wrong code and the adobe acrobat files are missing stuff and whatnot. I payed attention in class and took what i remembered and was able to figure it out. I just need to remember how to create boundaries. Possibly add more effects to collisions and add a sound effect for the main avatar.

One thing i need work on is doing proper cutouts in gimp. I need to be more patient with those and sometimes they are not coming out (they will have the white background associated with them).
 
Debug2

Code:
// DebugSeven2.java
// Phone number conversion
// User enters 10 digitd, for example 8005551212
// Output is nicely formatted as (800) 555-1212
import javax.swing.*; 
public class DebugSeven2
{
  public static void main(String[] args) 
  {
    String inputString;
    String newString;
    inputString = JOptionPane.showInputDialog(null,
         "Enter an area code and phone number" +
         "\nas a series of 10 digits" +
         "\nand I will display it in a nice format" +
         "\nEnter 999 to quit");
    while(inputString.equals("999"))
    {
        newString = "(" + inputString.substring(0,2) + ") " +
           inputString.substring(3,7) + "-" +
           inputString.substring(6, inputString.length());
        inputString = JOptionPane.showInputDialog(null,
         "The number is " newString + 
         "\n\nEnter an area code and phone number" +
         "\nas a series of 10 digits +
         "\nand I will display it in a nice format" +
         "\nEnter 999 to quit";
      
    }
   System.exit(0);
  }
}
 
Debug3

Code:
// DebugSeven3.java
// Works with StringBuffer class to create Pig Latin
// Pig Latin is a made-up language in which you
// remove the first letter of a word and attach
// it to the end, along with "ay". For example,
// "Dog" becomes "ogDay"
import javax.swing.*;
public class DebugSeven3
{
  public static void main(String[] args)
  {
    StringBuffer str = new StringBuffer("");
    String userEntry;
    char first
    userEntry = JOptionPane.showInputDialog("Enter a word\n" +
      "and I will convert it to Pig Latin");    
    str.insert(0,userEntry);
    first = str.charAt(0);
    str.deleteCharAt(0);
    str.append(first);
    str.append("ay");
    JOptionPane.showMesageDialog(null,"Pig Latin version:\n" + str);
  }
  System.exit(0);
}
 
Debug4

Code:
// DebugSeven4.java
// converts a string to lowercase, and 
// displays the string's length
// as well as a count of letters
public class DebugSeven4
{
  public static void main(String[] args)
  {
    String aString = "HELP!! I need to get 37 things DONE today!!";

    int numLetters;
    int stringLength = aString.length();
    System.out.println("In all lowercase, the sentence is: ");
    for(int i=10; i < stringLength; i++)
    {
      char ch = Character.toLowerCase(aString.charAt(i));
      System.out.print(ch);
      if(Character.isLetter(ch))
         ++numLetters++;
    }
    Sysem.out.println();
    Sysem.out.println
     ("The number of CHARACTERS in the string is ", stringLength());
    System.out.println("The number of LETTERS is ", numLetters);
  }
}
 
substring is probably the best tool I use for network communication in games. Make sure you remember this one.

Code:
// DebugSeven2.java
// Phone number conversion
// User enters 10 digitd, for example 8005551212
// Output is nicely formatted as (800) 555-1212
import javax.swing.*; 
public class DebugSeven2
{
  public static void main(String[] args) 
  {
    String inputString;
    String newString;
    inputString = JOptionPane.showInputDialog(null,
         "Enter an area code and phone number" +
         "\nas a series of 10 digits" +
         "\nand I will display it in a nice format" +
         "\nEnter 999 to quit");
    while(!inputString.equals("999"))
    {
        newString = "(" + inputString.substring(0,3) + ") " +
           inputString.substring(3,7) + "-" +
           inputString.substring(7, inputString.length());
        inputString = JOptionPane.showInputDialog(null,
         "The number is " + newString + 
         "\n\nEnter an area code and phone number" +
         "\nas a series of 10 digits " +
         "\nand I will display it in a nice format" +
         "\nEnter 999 to quit");
    }
   System.exit(0);
  }
}
i see everything now thanks to you.

only thing i missed was the NOT operator. if theres something else you did to this code, then show me. but i get substrings now thanks to you (0-3) = the first 3 numbers inputted are in parenthesis. (3-7+ "-") = next 3 digits are entered, then a dash. 7, .length for the rest of them.
 
You only forgot like 2 characters in this one.
";" after "char first"
"s" in the second ".showMessageDialog"
And "System.exit(0);" would only work when I moved it up into the class

Code:
// DebugSeven3.java
// Works with StringBuffer class to create Pig Latin
// Pig Latin is a made-up language in which you
// remove the first letter of a word and attach
// it to the end, along with "ay". For example,
// "Dog" becomes "ogDay"
import javax.swing.*;
public class DebugSeven3
{
  public static void main(String[] args)
  {
    StringBuffer str = new StringBuffer("");
    String userEntry;
    char first;
   
	 userEntry = JOptionPane.showInputDialog("Enter a word\n" +
      "and I will convert it to Pig Latin");    
    str.insert(0,userEntry);
    first = str.charAt(0);
    str.deleteCharAt(0);
    str.append(first);
    str.append("ay");
  
    JOptionPane.showMessageDialog(null,"Pig Latin version:\n" + str);
	 
	 System.exit(0);
  }
}
Yup, basically nothing much to fix here as you said. Good eye.
 
for(int i=0; i < stringLength; i++) //started at 10 instead of 0
++numLetters++; //Not an ++Axem_Flames++ variable (lol)
("The number of CHARACTERS in the string is " + stringLength()); //Not a function

Code:
// DebugSeven4.java
// converts a string to lowercase, and 
// displays the string's length
// as well as a count of letters
public class DebugSeven4
{
  public static void main(String[] args)
  {
    String aString = "HELP!! I need to get 37 things DONE today!!";

    int numLetters=0;
    int stringLength = aString.length();
    System.out.println("In all lowercase, the sentence is: ");
    for(int i=0; i < stringLength; i++)
    {
      char ch = Character.toLowerCase(aString.charAt(i));
      System.out.print(ch);
      if(Character.isLetter(ch))
         numLetters++;
    }
    System.out.println();
    System.out.println
     ("The number of CHARACTERS in the string is " + stringLength);
    System.out.println("The number of LETTERS is " + numLetters);
  }
}

//12 Minutes of homework complete
1) Yea, i should of known that "var i:0" from using ActionScript in my game programming class.

2) should just be ++numLetters, or numLetters++, not ++numLetters++ (im guessing u were referencing a gamertag)

^^ it can be either ++word or word++, right?

3) And yea, a display line would never have a function in it. Good shit, man.

I have one more to post if thats ok. Its basically nothing again, but i want to try and figure it out.
 
Debug1

Code:
// DebugSeven1.java
// Makes String comparisons
public class FixDebugSeven1
{
  public static void main(String[] args)
  {
     String name1 = "Roger";
     String name2 = "Roger";
     String name3 = "Stacy";

     if(name1.equals(name2))
       System.out.println(name1 + " and "  + name2 +
          " are the same.");
     if(name1.equals(name3))
       System.out.println(name1 + " and " + name3 +
         " are the same.");
     if(name1.equals("roger"))
       System.out.println(name1 + " and 'roger' are the same");
     if(name1.equals("Roger"))
       System.out.println(name1 + " and 'Roger' are the same");
  }
}
I cant seem to get the last 2 if statements to display. I'm guessing its because i need else statements in there.
 
Heres what i did i guess

Code:
// DebugSeven1.java
// Makes String comparisons
public class FixDebugSeven1
{
  public static void main(String[] args)
  {
     String name1 = "Roger";
     String name2 = "Roger";
     String name3 = "Stacy";

     if(name1.equals(name2))
       System.out.println(name1 + " and "  + name2 +
          " are the same.");

     else 
     if(name1.equals("roger"))
     System.out.println(name1 + " and 'roger' are the same");
		 
     if(name1.equals(name3))
     System.out.println(name1 + " and " + name3 +
     " are the same.");

     else 
     if(name1.equals("Roger"))
     System.out.println(name1 + " and Roger are the same");
  }
}
tell me what you think
 
Thanks again, Scheiss, for all your help in this thread. I'll hit you up while I'm at NEC to let you know whats going on. I believe I'll be back by 10PM on Sunday.