my program won't even run so i must have missed something drastically but i don't see it....
anyway, Create a class called Factor that has a public method called calculateFactor. The method has two two arguments of type integer and checks whether the smaller of the two integers is a factor of the larger of the two integers. The method will return a factor or a zero. Write a main method which repeatedly reads in a positive integer n (exiting only when n is negative), and displays out the largest proper divisor of n (that is, the largest factor of n that is less than n itself).
This is what i have:

import java.io.*;
import java.util.*;

class Factor{
public int calculateFactor(int n1, int n2){
int factor =0;
if(factor==0)
	return 0;
else {
return factor;
}//end public
}//end class

public class lab7_1 {
public void main(String[]args){
System.out.print("input an integer number:");
Factor f= new Factor();
int n;
n=0;
int i;
i=2;
double value;
value=f.calculateFactor(i,n);
while(i<=n)
System.out.print("largest divisor");
}

}
}

Recommended Answers

All 2 Replies

public static void main (String args[])
{
// code here
}

You forgot the static keyword.

my program won't even run so i must have missed something drastically but i don't see it....

Excellent analysis of the problem, also let me congratulate you on the wonderful code alignment technique you have pioneered.
Also do not directly copy paste your assignment.

Here are a few pointers you need to look into

  1. while and do while loops in Java - Look here.
  2. Reading an Integer from Console in Java
  3. Sun Java Code Conventions, no need to read the whole document, just go through the basic parts related to code indentation, variable naming etc.

And Vernon already has pointed out the "main" part

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.