Im trying to make a program that does a formula and the user imputs the variables and it prints the result.
I dont know terminology, so im just gona call this the class with the formula
//Geometeric Series - Sn = (1-r^(n-1))/(1-r) public class geometricSeries { public static double geometricSeries(double a, int n, double r) { double sum = (1-(Math.pow(r,n)))/(1-r); return sum; } }
This is the user imput part i have a problem with
import java.util.Scanner; public class geometricSeriesDriver { public static void main(String[]args); { System.out.println("Imput the first term"); Scanner scan = new Scanner(System.in); double a = scan.nextDouble; System.out.println("Imput the n term"); int n = scan.nextInt; System.out.prinln("Imput the ratio"); double r = scan.nextDouble; return sum; } }
I have no idea how to connect the two, its been like 2 weeks since ive written code and im just starting so i kind of forgot how. Also i get these errors.
geometricSeriesDriver.java:5: error: missing method body, or declare abstract
public static void main(String[]args);
^
geometricSeriesDriver.java:10: error: cannot find symbol
double a = scan.nextDouble;
^
symbol: variable nextDouble
location: variable scan of type Scanner
geometricSeriesDriver.java:13: error: cannot find symbol
int n = scan.nextInt;
^
symbol: variable nextInt
location: variable scan of type Scanner
geometricSeriesDriver.java:15: error: cannot find symbol
System.out.prinln("Imput the ratio");
^
symbol: method prinln(String)
location: variable out of type PrintStream
geometricSeriesDriver.java:16: error: cannot find symbol
double r = scan.nextDouble;
^
symbol: variable nextDouble
location: variable scan of type Scanner
geometricSeriesDriver.java:18: error: return outside method
return sum;
^
6 errors