This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide and have Khalid Mughal and Vasily Strelnikov on-line!
See this thread for details.

Mark Rem

Greenhorn
+ Follow
since Dec 11, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Mark Rem

For some reason, I'm getting an error. It doesn't seem to be reading my "input.txt" file. I'm trying to read the "input.txt" file which consits of random integers and use insertion sort to sort them in order. Then, i want to have the sorted integers go the file "output.txt"

static final int MAX_NUM = 100;

public static void main( String[] args ) throws java.io.IOException
{
int[] num = new int[MAX_NUM];

FileReader fr = new FileReader("input.txt");
BufferedReader br = new BufferedReader( fr );
PrintWriter out = new PrintWriter( new BufferedWriter( new FileWriter( "output.txt" ) ) );

int count = 0;
while ( count < MAX_NUM )
{
String line = br.readLine();
if( (line == null) || line.equals( "" ) )
break;
try
{
num[count] = Integer.parseInt( line );
count++;
}
catch( Exception e)
{
System.out.println( "ERROR" );
}
//System.out.println( line );
//line = br.readLine();
}


insertionSort( num );

for( int i = 0; i < count; i++ )
{
out.println( Integer.toString( num[i] ) );
}

out.close();
}
20 years ago

Originally posted by vinodkumar kt:
check this
roundup int (int x){

int y;
if(x%10 != 0){
y=((x/10)+1)*10;
}else{
y=x;
}
return y;
}





You're cool man, thanks a lot!
20 years ago
How about this algorithm?

int roundUp( int )
{
int input, rem, x;

input % 10 = rem;
if( rem >= 1 && < 10 )
{
x = ( 10 - rem ) + input;
}

return ;
}
20 years ago
int roundUp( int )
{
int x, y;
x % 10 = y;
if( y >= 1 && y < 9 )
{
y = y + 10;
}

return y;
}
20 years ago
How would I go about creating an algorithm that would round up a positive integer by 10. For example, 1 -> 10; 11 -> 20; 91 -> 100.
20 years ago
How would I show progressive refinements for a function getAjob()?
20 years ago
hey, what would be somme operations for this function? Can anyone start me off?
20 years ago
What are some examples of operation if i were to make an ADT for an online book?
20 years ago
what about if my TreeNode class is in my BinarySearchTree class?
How can pass it as a parameter to the breadthFirst()
20 years ago
I'm trying to implement a Breadth-first traversal in the application class use a queue and a binarysearchtree..I'm getting an error

public void breadthFirst( TreeNode tNode)
{
Queue q = new Queue( );
if( q.isEmpty() )
{
q.enqueue( this );
}

while( !q.isEmpty() )
{

}

}

E:\ICS\ICS 211 Projects (Fall 04)\Final Exam\211final_src\FinalDataTypesTest.java:11: cannot resolve symbol
symbol : class TreeNode
location: class FinalDataTypesTest
public void breadthFirst( TreeNode tNode)
^
1 error
20 years ago
ADT
I am a beginner to this whole java thing. It almost seems foreign to me. I was asked to create an ADT for an online book? what are examples of some operations?
20 years ago
I don't even know how to get started..
20 years ago
I'm fairly new to java and I have this assignment to do? How would i go about doing this?

Implement a program which computes the following recurrence relation:

f(1) = 1; f(2) = 1; f(3) = 1; f(4) = 1; f(5) = 1;

f(n) = f( n - 1 ) + 3 * f( n - 5 ) for all n > 5

Display the results for n = 6, 7, 12, and 15
20 years ago