Code Monkey home page Code Monkey logo

bell-kevin / milespergallonofgas Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jcboydsd/milespergallon

0.0 0.0 0.0 16 KB

SDEV 2210 Project. Create a project that calculates miles per gallon for a given trip, and accumulates the miles and gallons to calculate an overall MPG for the vehicle. Create a class named MPG that includes private instance variables for miles, gallons, and mpg, which are doubles. Add class variables for totalMiles, totalGallons, and totalMPG, which are doubles, and numTrips, which is an integer. Create a constructor which accepts 2 double parameters, one for miles, one for gallons. Inside the constructor, set the instance variables for miles and gallons, and calculate the mpg. Add to the class variables for totalMiles and TotalGallons, and increment the number of trips. Create an instance method named displayCurrentMPG( ) which displays the MPG variable for a specific trip object. Create a class method named displayTotalMPG( ) which calculates and displays the overall MPG for all of the trip objects. The driver class will instantiate 4 trips, display the MPG for each trip, and display the overall MPG. For the sample session, use the following values: Trip1: miles = 320, gallons = 29 Trip2: miles = 325.8, gallons = 32.1 Trip3: miles = 412.5, gallons = 35 Trip4: miles = 345, gallons = 32.6 Note that these 4 trips test all the possible combinations of variable types – 2 integers, 2 doubles, 1 integer and 1 double, 1 double and 1 integer. It’s always good practice to test all possible situation. Once the program works as it should to match the sample session, run the project twice more, with different numbers for every trip, and take screenshots of the results.

Java 100.00%
2210 datc davis davistech gas gasoline miles mpg object-oriented-programming oop sdev sdev2210 tech

milespergallonofgas's Introduction

Hi πŸ‘‹, I'm Kevin Bell

I'm a student!

  • 🀝 I’m looking to collaborate on almost anything open-source.
  • πŸ”¨ I’m currently working on my Computer Science degree.

GitHub Streak

πŸ› οΈ My favorite tools

πŸ‘¨β€πŸ’» Programming and markup languages

C++ CSS HTML Java JavaScript Scratch SQL

🧰 Frameworks and libraries

GitHub Actions JUnit TensorFlow Wordpress

πŸ—„οΈ Databases and cloud hosting

GitHub Pages MySQL

πŸ’» Software and tools

Android Brave Discord Git GitHub Desktop Google Sheets Stack Overflow Visual Studio Code

I love free/libre open-source software! Most JavaScript running on most websites (including GitHub.com) is NOT open-source software.

milespergallonofgas's People

Contributors

bell-kevin avatar jcboydsd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.