A shuttle van picks up passengers and drives them to a destination, where they leave the van. Keep a count of the boarding passengers, but don't allow boarding if the van is full. Update the odometer when the van drives. Van.java 1 /** This class models a shuttle van. */ 4 public class Van // Instance variables /** Constructs a van with a given capacity. @param maxPassengers the maximum number of passengers that this van can hold */ public Van(int maxPassengers) { 10 11 12 13 14 15 16 17 18 19 20 21 55 } /** Boards passengers up to the capacity of this van. @param boardingPassengers the number of passengers attempting to board */ public void board(int boardingPassengers) { 25 26 27 28 } /** Drives the van and discharges the passengers. @param distance the distance driven */ public void drive(double distance) { } 38 40 41 42 43 /** Gets the number of passengers in this van. @return the number of passengers */ public int getPassengers() { 44 45 46 47 48 49 50 51 /** Gets the number of miles that this van has driven. @return the number of miles */ public double getMilesDriven(O 53 54 55 } VanTester.java 1 public class VanTester 2 { public static void main(String[) args) { Van vanl = new Van(8); vanl.board (3); System.out.println(van1.getPassengers()); System.out.println("Expected: 3"); vani, boardien System.out.println(van1.getPassengers()); System.out. - out.println("Expected: 8"); van1.drive(10); System.out.println(vanl.getPassengers()); ystem. out.println("Expected: 0"); . out.println(van1.getMilesDriven()); System.out. System.out.println("Expected: 10"); van1. board(6) System.out.println(van1.getPassengers()); System.out.println("Expected: 6"); van1.drive(12); System.out.println(van1.getPassengers()); System.out.println("Expected: 0"); System.out.println(van1.getMilesDriven()); System.out.println("Expected: 22"); } 25 26
A shuttle van picks up passengers and drives them to a destination, where they leave the van. Keep a count of the boarding passengers, but don't allow boarding if the van is full. Update the odometer when the van drives. Van.java 1 /** This class models a shuttle van. */ 4 public class Van // Instance variables /** Constructs a van with a given capacity. @param maxPassengers the maximum number of passengers that this van can hold */ public Van(int maxPassengers) { 10 11 12 13 14 15 16 17 18 19 20 21 55 } /** Boards passengers up to the capacity of this van. @param boardingPassengers the number of passengers attempting to board */ public void board(int boardingPassengers) { 25 26 27 28 } /** Drives the van and discharges the passengers. @param distance the distance driven */ public void drive(double distance) { } 38 40 41 42 43 /** Gets the number of passengers in this van. @return the number of passengers */ public int getPassengers() { 44 45 46 47 48 49 50 51 /** Gets the number of miles that this van has driven. @return the number of miles */ public double getMilesDriven(O 53 54 55 } VanTester.java 1 public class VanTester 2 { public static void main(String[) args) { Van vanl = new Van(8); vanl.board (3); System.out.println(van1.getPassengers()); System.out.println("Expected: 3"); vani, boardien System.out.println(van1.getPassengers()); System.out. - out.println("Expected: 8"); van1.drive(10); System.out.println(vanl.getPassengers()); ystem. out.println("Expected: 0"); . out.println(van1.getMilesDriven()); System.out. System.out.println("Expected: 10"); van1. board(6) System.out.println(van1.getPassengers()); System.out.println("Expected: 6"); van1.drive(12); System.out.println(van1.getPassengers()); System.out.println("Expected: 0"); System.out.println(van1.getMilesDriven()); System.out.println("Expected: 22"); } 25 26
Chapter6: Looping
Section: Chapter Questions
Problem 4GZ
Related questions
Question
100%
![A shuttle van picks up passengers and drives them to a destination, where they leave the van. Keep a count of the boarding passengers, but don't allow boarding if the van is full. Update the odometer when the van drives.
Van.java
1 /**
This class models a shuttle van.
*/
4 public class Van
// Instance variables
/**
Constructs a van with a given capacity.
@param maxPassengers the maximum number of passengers that this
van can hold
*/
public Van(int maxPassengers)
{
10
11
12
13
14
15
16
17
18
19
20
21
55
}
/**
Boards passengers up to the capacity of this van.
@param boardingPassengers the number of passengers attempting
to board
*/
public void board(int boardingPassengers)
{
25
26
27
28
}
/**
Drives the van and discharges the passengers.
@param distance the distance driven
*/
public void drive(double distance)
{
}
38
40
41
42
43
/**
Gets the number of passengers in this van.
@return the number of passengers
*/
public int getPassengers()
{
44
45
46
47
48
49
50
51
/**
Gets the number of miles that this van has driven.
@return the number of miles
*/
public double getMilesDriven(O
53
54
55 }
VanTester.java
1 public class VanTester
2 {
public static void main(String[) args)
{
Van vanl = new Van(8);
vanl.board (3);
System.out.println(van1.getPassengers());
System.out.println("Expected: 3");
vani, boardien
System.out.println(van1.getPassengers());
System.out.
- out.println("Expected: 8");
van1.drive(10);
System.out.println(vanl.getPassengers());
ystem. out.println("Expected: 0");
. out.println(van1.getMilesDriven());
System.out.
System.out.println("Expected: 10");
van1. board(6)
System.out.println(van1.getPassengers());
System.out.println("Expected: 6");
van1.drive(12);
System.out.println(van1.getPassengers());
System.out.println("Expected: 0");
System.out.println(van1.getMilesDriven());
System.out.println("Expected: 22");
}
25
26](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F3200e892-7b83-4670-8aa5-c4c84f2a6adb%2Fd6a2dda5-b0df-4ef4-992d-8783506b6748%2Fd983rfv.png&w=3840&q=75)
Transcribed Image Text:A shuttle van picks up passengers and drives them to a destination, where they leave the van. Keep a count of the boarding passengers, but don't allow boarding if the van is full. Update the odometer when the van drives.
Van.java
1 /**
This class models a shuttle van.
*/
4 public class Van
// Instance variables
/**
Constructs a van with a given capacity.
@param maxPassengers the maximum number of passengers that this
van can hold
*/
public Van(int maxPassengers)
{
10
11
12
13
14
15
16
17
18
19
20
21
55
}
/**
Boards passengers up to the capacity of this van.
@param boardingPassengers the number of passengers attempting
to board
*/
public void board(int boardingPassengers)
{
25
26
27
28
}
/**
Drives the van and discharges the passengers.
@param distance the distance driven
*/
public void drive(double distance)
{
}
38
40
41
42
43
/**
Gets the number of passengers in this van.
@return the number of passengers
*/
public int getPassengers()
{
44
45
46
47
48
49
50
51
/**
Gets the number of miles that this van has driven.
@return the number of miles
*/
public double getMilesDriven(O
53
54
55 }
VanTester.java
1 public class VanTester
2 {
public static void main(String[) args)
{
Van vanl = new Van(8);
vanl.board (3);
System.out.println(van1.getPassengers());
System.out.println("Expected: 3");
vani, boardien
System.out.println(van1.getPassengers());
System.out.
- out.println("Expected: 8");
van1.drive(10);
System.out.println(vanl.getPassengers());
ystem. out.println("Expected: 0");
. out.println(van1.getMilesDriven());
System.out.
System.out.println("Expected: 10");
van1. board(6)
System.out.println(van1.getPassengers());
System.out.println("Expected: 6");
van1.drive(12);
System.out.println(van1.getPassengers());
System.out.println("Expected: 0");
System.out.println(van1.getMilesDriven());
System.out.println("Expected: 22");
}
25
26
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781337671385/9781337671385_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
![EBK JAVA PROGRAMMING](https://www.bartleby.com/isbn_cover_images/9781305480537/9781305480537_smallCoverImage.jpg)
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning