RSS Forums RSS

Need help with a very simple Java program

Please support our Java advertiser: Programming Forums
Thread Solved
Reply
Posts: 14
Reputation: Magda is an unknown quantity at this point 
Solved Threads: 0
Magda's Avatar
Magda Magda is offline Offline
Newbie Poster

Help Need help with a very simple Java program

  #1  
Nov 15th, 2007
Hi all,

I need to write this program today and I really struggle :-( Would you be able to help at all?

public class ISPN
{
private int[] authorId;
private int[] programId;

/**
* Creates a new instance of ISPN
*/
public ISPN(int[] anAuthorId, int[] aProgramId) //constructor that takes two array arguments and uses them to set the values of author/program identifier)
{
// TODO

}

public boolean isValidLength() //method that returns true if author id and program id together compromise 6 integers, otheriwse false
{

return false;
}

public boolean isAllValidDigits() //method that returns true if author id and program id are in the valid range 0-9 inclusive, otherwise returns false

{
// TODO
return false;
}

public String getAuthorIdAsString()//method that returns string constructed by the digits in the array that represents author identifier
{
// TODO
return null;
}

public String getProgramIdAsString()
{
// TODO
return null;
}

public int calculateCheckDigit() //method that calculates the check digit and returns it as an int value
{
// TODO
return 0;
}

public String toString()
{
// TODO
return null;
}

public boolean equals(ISPN ispn)
{
// TODO
return false;
}
}
Many thanks

Magda
AddThis Social Bookmark Button
Reply With Quote  
Posts: 4,111
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 458
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is online now Online
Industrious Poster

Re: Need help with a very simple Java program

  #2  
Nov 15th, 2007
Sure, the first thing that would help is filling in those methods a bit more.

Did you have any other specific questions?
Reply With Quote  
Posts: 14
Reputation: Magda is an unknown quantity at this point 
Solved Threads: 0
Magda's Avatar
Magda Magda is offline Offline
Newbie Poster

Help Re: Need help with a very simple Java program

  #3  
Nov 15th, 2007
Originally Posted by Ezzaral View Post
Sure, the first thing that would help is filling in those methods a bit more.

Did you have any other specific questions?

Yes, please find the question below:

"imagine there's a proposal to develop an International Standard Program Number. Suppose the draft standard shall have the following structire:
an ISPN is always 8 characters long not counting the hyphens

- character 1 is an uppercase P to denote Program
- characters 2-7 are decimal digits representing an author identifier and program identifier. These are of variable length
- character 8 is a check digit in the range 0-8; the check digit is calculated by adding up all the digits of the author identifier and program identifier and then taking the reminder when the total is divided by 9, the check digit can larter be used to detect mistakes in copying the ISPN.

The class should contain the following methods:

1. a constructor that takes two array arguments and used them to set values of the author/program id
2. a method isValidLenght() that returns true if the author/program id together comprise 6 integegers, otherwise returns false
3. a method isAllValidDigits() that returns true if all the int values of author/program id are in the valid range 0-9 inclusive
4. a method getAuthorIdAsString that returns a string constructed by the digits in the author id array
5. a method getProgramIdAsString
6. a method calculateCheckDigit that calculates the check digit and returns it as an int value
7. a method toString that returns a string representing the ISPN

Many thanks

Magda
Reply With Quote  
Posts: 4,111
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 458
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is online now Online
Industrious Poster

Re: Need help with a very simple Java program

  #4  
Nov 15th, 2007
Originally Posted by Magda View Post
Yes, please find the question below:
<snipped>

No, posting your homework assignment does not constitute specific questions. You need to make an effort to complete the assignment on your own. If you have difficulties, then post the code and the errors or questions you cannot figure out.
Reply With Quote  
Posts: 14
Reputation: Magda is an unknown quantity at this point 
Solved Threads: 0
Magda's Avatar
Magda Magda is offline Offline
Newbie Poster

Help Re: Need help with a very simple Java program

  #5  
Nov 15th, 2007
Originally Posted by Ezzaral View Post
No, posting your homework assignment does not constitute specific questions. You need to make an effort to complete the assignment on your own. If you have difficulties, then post the code and the errors or questions you cannot figure out.

Of course I'd prefer to know how to do it than ask you for a solution.

This is what I've got :

package tma01q1;

public class ISPN
{
private int[] authorId;
private int[] programId;

/**
* Creates a new instance of ISPN
*/
public ISPN(int[] anAuthorId, int[] aProgramId)
{
//here i am not sure how to declare array arguments

}

public boolean isValidLength()
{
while
{
anAuthorId + aProgramID == 6
}
return true;
}

public boolean isAllValidDigits()
{
while
{
(anAuthorID >= 0 && anAuthorID <= 9) && (aProgramID >= 0 && aProgramID <= 9)
}
return true;
}
Reply With Quote  
Posts: 1
Reputation: londonlad is an unknown quantity at this point 
Solved Threads: 1
londonlad londonlad is offline Offline
Newbie Poster

Question Re: Need help with a very simple Java program

  #6  
Nov 15th, 2007
hi there,

I am stuck at somewhere same.

/* ISPN.java
* A class to represent an imaginary "International Standard Program Number"

*/

package tma01q1;

public class ISPN
{
private int[] authorId;
private int[] programId;

/**
* Creates a new instance of ISPN
*/
public ISPN(int[] anAuthorId, int[] aProgramId)
{
authorId = anAuthorId[] ;
programId = aProgramId[] ;
}

public boolean isValidLength()
{
if ((authorId.length + programId.length) == 6)


return true;

}

public boolean isAllValidDigits()
{
// TODO
return false;
}

public String getAuthorIdAsString()
{
// TODO
return null;
}

public String getProgramIdAsString()
{
// TODO
return null;
}

public int calculateCheckDigit()
{
// TODO
return 0;
}

public String toString()
{
// TODO
return null;
}

public boolean equals(ISPN ispn)
{
// TODO
return false;
}
}
Last edited by londonlad : Nov 15th, 2007 at 4:47 pm.
Reply With Quote  
Posts: 14
Reputation: Magda is an unknown quantity at this point 
Solved Threads: 0
Magda's Avatar
Magda Magda is offline Offline
Newbie Poster

Re: Need help with a very simple Java program

  #7  
Nov 15th, 2007
Many thanks for all your help. I've decided to give up on it today...will have a lesson for the future to do my assignments at least one week before the cut off date.

Take care,

Magda
Reply With Quote  
Posts: 1
Reputation: Joey Bumba is an unknown quantity at this point 
Solved Threads: 0
Joey Bumba Joey Bumba is offline Offline
Newbie Poster

Re: Need help with a very simple Java program

  #8  
Dec 7th, 2007
Originally Posted by londonlad View Post
hi there,

I am stuck at somewhere same.

/* ISPN.java
* A class to represent an imaginary "International Standard Program Number"

*/

package tma01q1;

public class ISPN
{
private int[] authorId;
private int[] programId;

/**
* Creates a new instance of ISPN
*/
public ISPN(int[] anAuthorId, int[] aProgramId)
{
authorId = anAuthorId[] ;
programId = aProgramId[] ;
}

public boolean isValidLength()
{
if ((authorId.length + programId.length) == 6)


return true;

}

public boolean isAllValidDigits()
{
// TODO
return false;
}

public String getAuthorIdAsString()
{
// TODO
return null;
}

public String getProgramIdAsString()
{
// TODO
return null;
}

public int calculateCheckDigit()
{
// TODO
return 0;
}

public String toString()
{
// TODO
return null;
}

public boolean equals(ISPN ispn)
{
// TODO
return false;
}
}


..
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 1581 | Replies: 7 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:35 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC