My professor wants me to write an object oriented program with Java, that solves some quadratic equation as many times as args[0] is defined, for example computer-:Desktop User$ java program_name 3 will iterate the programs 3 times.(I hope that's clear enough).
I have everything down, except the "object oriented program", I don't see how I can make it object oriented, the instructions don't leave me too much room to work (other than with a constructor method).
I've been trying to do this:
public class assignment {
assignment(double method_inp){
double coeff = method_inp;
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int input_number = Integer.parseInt(args[0]);
if (input_number > 0) {
for (int i = 0; i < input_number; i++) {
// isn't this object oriented?
assignment a = new assignment(readCoeff(input));
assignment b = new assignment(readCoeff(input));
assignment c = new assignment(readCoeff(input));
(readCoeff(input) just goes to scanner and lets the user input the value.
but it seems I can't use a, b and c as variables. nor convert them to variables, because they can't be converted to double. What can I do? is there a better way to make my program object oriented?
Edit: I can't use global variables
Edit: Content of readCoeff(input) is:
static double readCoeff(Scanner inn) {
System.out.print("Please enter coefficient of a quadratic equation: ");
return inn.nextDouble();
readCoeff?