Image

Imagei_like_jessie_f wrote in Imagejava_dev 😟anxious

Listens: De la Soul - Church

First post, yeah i'm a java weakling.

Hello guys this is my first post in this community. My name is Jamie Witter and i'm an information systems major, i've got no programming experience and all my computer experience has to do with hardware which i love. I'm currently taking a Java Programming course and i'm currently doing an assignment in which i've run into some problems. It's my first experience with making my own class and to me my code looks fine but it's just not working when i test it. I'm sure there are plenty of people here knowledgable enough to simply just point out my mistake, i've looked at The Java White paper and googled a few pages for help but i just cant seem to figure it out, my teacher hasn't been of much help all semester so i've basically been teaching myself which has resulted in me being a horrid programmer. Behind the cut i've thrown what i've got so far any helped would really be appreciated; i'm sure it's something small because those are my tendencies but better to be called an idiot than to never learn what i'm doing wrong i guess.



public class Student
{

 public double firstTest, secondTest;
 public String name;
 public Student() //default constructor should be initialized with Kevin, 92 and 85.
		{
        name = "Kevin"; 
		  firstTest = 92;
		  secondTest = 85;
       }
 public Student(double firstTest) //constructor with one argument that initializes the firstTest only, by default, name would be null and secondTest would be zero
 		{
		 this.firstTest = firstTest;
		 name = new String ("");
		 secondTest = 0.0;
		}
public Student(String name, double firstTest, double secondTest)//constructor initializes the name, firstTest and secondTest.
 		{
		this.name = name;
		this.firstTest = firstTest;
		this.secondTest = secondTest;
		}
public String getName()//returns name.
      {
		return name;
		}
public double getFirstTest()//returns firstTest.
		{
		return firstTest;
		}
public double getSecondTest()//returns secondTest.	 
		{
		return secondTest;
		}
public void setName(String newName)//replaces the name with newName
		{
		this.name = newName;
		}
public void firstNumber(double newNumber)// replaces firstTest with newNumber
		{
		this.firstTest = newNumber;
		}
public void secondNumber(double newNumber)// replaces secondTest with newNumber.
		{
		this.secondTest = newNumber;
		}
public void swapTests()// swaps firstTest to secondTest and vice-versa.
 		{
		double tempTest = 0.0;
		tempTest = firstTest;
		firstTest = secondTest;
		secondTest = tempTest;
		}
public double getAverage()//returns the average of firstTest and secondTest.
		{
		double average = (firstTest + secondTest)/2;
		return average;
		}
public boolean isFirstTestGreater()// returns true if firstTest is greater than secondTest
 		{
				if (firstTest == secondTest)
				{
					System.out.println ("True");
				}
				return true;
		}
		
 }

=====================================================================

public class StudentTest
{
	public static void main(String [] args)
	{
		Student unknown1 = new Student(); // Create an object unknown1 with the default constructor.
		System.out.println (unknown1); //Print out the name, firstTest and secondTest of unknown1
		
		Student unknown2 = new Student(75.0);//Create another object unknown2 with constructor public Student(double firstTest) with argument 75.0
		System.out.println (unknown2); //Print out the name, firstTest and secondTest of unknown2.
	}
	
}


when i run the test program using the classes i get "Student@119c082
Student@1add2dd" as my output =(.