| | |
Need help with a very simple Java program
Thread Solved |
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
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
•
•
•
•
Sure, the first thing that would help is filling in those methods a bit more.
Did you have any other specific questions?
"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
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.
•
•
•
•
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.
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;
}
•
•
Join Date: Nov 2007
Posts: 1
Reputation:
Solved Threads: 1
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;
}
}
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 5:47 pm.
•
•
Join Date: Dec 2007
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
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;
}
}
..
![]() |
Similar Threads
- install and run tomcat3 and implement a simple jsp page (JSP)
- put the Dos 's command into java program? (Java)
- Running Java Program outside an IDE (Java)
- java program to calculate simple interest (Java)
- JAVA program help (Student/Grades) (Java)
- Help with a java program home work assignment (Java)
- writing a simple cat program (C)
- Error message when running simple Java pgm (Java)
- Help with simple Java IO program running under cygwin (Java)
Other Threads in the Java Forum
- Previous Thread: PacMan Boolean Problem Part Duex.
- Next Thread: Java ME
| Thread Tools | Search this Thread |
-xlint add android api applet application applications array arrays automation bank bi binary blackberry bluetooth chat class clear client code compile compiler component database development digit eclipse equation error event formatingtextintooltipjava fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image infinite int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list main map method methods mobile myregfun netbeans nonstatic notdisplaying openjavafx pearl problem program project qt recursion repositories scanner screen scrollbar server set sms sort sorting spamblocker sql sqlserver state storm string superclass swing system thread threads tree variablebinding windows xor






