Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CS570-Java_Projects
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bjv33
CS570-Java_Projects
Commits
d05fa903
Commit
d05fa903
authored
6 years ago
by
bjv33
Browse files
Options
Downloads
Patches
Plain Diff
Motorboat Class
parent
05f1160d
Branches
master
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Motorboat.java
+64
-0
64 additions, 0 deletions
Motorboat.java
with
64 additions
and
0 deletions
Motorboat.java
0 → 100644
+
64
−
0
View file @
d05fa903
// Program: MotorBoat.java
// Purpose: This program calculates a motorboats fuel efficiency through distance.
// Author: Brian Vojtko
// Date: 10/16/2018
import
java.util.Scanner
;
public
class
Motorboat
{
Scanner
input
=
new
Scanner
(
System
.
in
);
//Integers
private
double
tankCapacity
=
50
;
private
double
fuelInTank
=
0
;
private
double
maxSpeed
=
90
;
double
currentSpeed
=
0
;
private
double
motorEfficiency
=
0.43
;
double
distanceTraveled
=
0
;
//Constructor that sets the tank level, speed, and efficiency
public
void
start
(
double
tankLevel
,
double
speed
,
double
efficiency
)
{
tankCapacity
=
tankLevel
;
fuelInTank
=
0
;
maxSpeed
=
speed
;
currentSpeed
=
0
;
motorEfficiency
=
efficiency
;
distanceTraveled
=
0
;
}
//Integers placed in Constructors
double
fuelLeft
;
double
gallonsLeft
=
motorEfficiency
*
(
maxSpeed
/
2
);
double
gallonsLeftRefuel
=
(
motorEfficiency
*
(
maxSpeed
/
2
)
+
10
);
//Set the fuel tank
public
double
tank
()
{
return
tankCapacity
;
}
//Set the speed of the boat
public
double
userSpeed
(){
return
maxSpeed
;
}
//Amount of fuel remaining
public
double
fuelRemaining
()
{
return
fuelLeft
;
}
//Amount of fuel remaining after distance
public
double
efficient
()
{
return
gallonsLeft
;
}
//Distance traveled
public
double
distance
()
{
return
maxSpeed
/
2
;
}
//Fuel after refill
public
double
refuel
()
{
return
gallonsLeftRefuel
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment