java - new error: Actual and formal argument lists differ in length -
trying finish assignment first year comp class. far everything's been okay, can't figure 1 error out. wondering if out here? tried changing variables doubles , didnt work.
import java.util.scanner; public class cellphoneprogram { public static scanner keyboard = new scanner(system.in); //declare x , y coordinates each city public static double xa = 100, xb = 100, xc = 340, xd = 230, ya = 360, yb = 360, yc = 250, yd = 140; public static int getrange(int city) { int range = 0; system.out.println("what maximum distance (in km) center of city " + city + " may travel without losing service?"); range = keyboard.nextint(); return range; } /* error occurs here */ public static double distance(double xf, double xi, double yf, double yi) { double distance = 0; distance = math.sqrt((math.pow(xf - xi)) - (math.pow(yf - xi))); return distance; } public static void main(string[] args) { int city1, city2, city3, city4; double distance1, distance2, distance3; system.out.println("welcome cell phone service program, enter range of service 4 cities," + " , calculate whether or not lose service."); //get range function city1 = getrange(1); city2 = getrange(2); city3 = getrange(3); city4 = getrange(4); system.out.println(city3); //calculate distances cities distance1 = distance(xb, xa, yb, ya); distance2 = distance(xc, xb, yc, yb); distance1 = distance(xd, xc, yd, yc); system.out.println(distance1); } }
here's @ error:
file: c:\users\katie\documents\homework\cellphoneprogram.java [line: 16] error: method pow in class java.lang.math cannot applied given types; required: double,double found: double reason: actual , formal argument lists differ in length file: c:\users\katie\documents\homework\cellphoneprogram.java [line: 16] error: method pow in class java.lang.math cannot applied given types; required: double,double found: double reason: actual , formal argument lists differ in length
this code still in progress, sorry messiness , incomplete code , that.
math.pow() requires 2 arguments not one. guessing want raise second power second argument should 2.
math.sqrt((math.pow(xf - xi,2)) - (math.pow(yf - xi,2)));
see http://docs.oracle.com/javase/7/docs/api/java/lang/math.html#pow%28double,%20double%29
Comments
Post a Comment