Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Mark Rem

Greenhorn
+ Follow
since Dec 11, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

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();
}
16 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!
16 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 ;
}
16 years ago
int roundUp( int )
{
int x, y;
x % 10 = y;
if( y >= 1 && y < 9 )
{
y = y + 10;
}

return y;
}
16 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.
16 years ago
How would I show progressive refinements for a function getAjob()?
17 years ago
hey, what would be somme operations for this function? Can anyone start me off?
17 years ago
What are some examples of operation if i were to make an ADT for an online book?
17 years ago
what about if my TreeNode class is in my BinarySearchTree class?
How can pass it as a parameter to the breadthFirst()
17 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
17 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?
17 years ago
I don't even know how to get started..
17 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
17 years ago