Introductory Java Student assigning an existing variable to another -
my apologies if seems simple question, new computer science student , question has me stumped.
suppose car variable billscar exists , refers car object. write statement assigns billscar's unused capacity double variable amtleft.
below source code:
public class car{ // car attributes string make; // manufacturer double fuelcapacity; double fuelamount; // car constructor public car(string what, double cap, double amt){ make = what; fuelcapacity = cap; fuelamount = amt; } // car methods public string getmake(){ return make; } public double getcapacity(){ return fuelcapacity; } public double getfuel(){ return fuelamount; } public void setfuel(double amt){ fuelamount = amt; } public double unusedcap(){ return (fuelcapacity - fuelamount); } }
the answer block begins double amtleft = ; proper way of assigning billscar unused capacity (a varible not know) double variable amtleft?
change unusedcap() this?
public double unusedcap() { double fuelleft=(fuelcapacity - fuelamount); return fuelleft; }
Comments
Post a Comment