MyBmw.takeTrip(100) // Takes away the fuel used for 100 miles using the takeTrip methodĭouble fuel_left = myBmw.Raleigh-Durham, North Carolina Area Community Manager at Camden Property Trust Real Estate Education Western Carolina University 2006 - 2008 Bachelor of Science, Communication: Broadcasting & Broadcast Sales University of West Florida 2004 - 2006 Telecommunication & Film Experience Camden Property Trust November 2014 - Present Firefly Hot Yoga January 2014 - November 2014 Camden Property Trust January 2012 - December 2012 Greystar January 2010 - January 2011 Fairfield Residential April 2009 - January 2010 The Executive Staffing Group January 2009 - April 2009 WRGC 680-AM August 2008 - December 2008 Western Carolina University June 2008 - December 2008 Clear Channel Radio June 2007 - August 2007 Pacific Sunwear October 2004 - April 2005 Skills Spanish, Customer Service, Social Media, Sales, Social Media Marketing, Property Management, Event Planning, Marketing, Microsoft Office, Social Networking, Advertising, Facebook, Yardi, Sales Management, Market Research, Cold Calling, Editing, Online Marketing, Contract Negotiation Show more MyBmw.fillUp(20) // Adds 20 gallons to fillUp method Public double reportFuel() // Returns value of how much fuel is left in tankĪnd this is the Tester class: public class TesterĪutomobile myBmw = new Automobile(24) // Passes constructor argument of 24 mpg Shouldn't it do gallons = gallons - (miles driven / mpg)? For some reason, when I reference mpg, the output of Tester is "-infinity".
Gallons -= t / mpg // Not sure how to do this line. Public void takeTrip(double t) // Takes away fuel from the tank depending upon how many miles are driven Public void fillUp(double f) // Adds fuel to the tank Public Automobile(double m) // Accepts value m to the double mpg. This is the Automobile class: public class Automobile When I leave that method out of the Tester class, it returns the correct values. I can't figure out why, other than that I've singled out the problem is in the Automobile class at line 14 in the takeTrip method. Every time I run the Tester class, it returns a value of -Infinity.
The other class, Tester, is the main class. It asks to create two classes, one is Automobile which holds the methods I will work with. I'm working on a project from the Blue Pelican Java book, lesson 16 project Gas Mileage.