Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could you create a UML flowchart for the following code, Preferably in the software DIA or Microsoft Word whichever is easier. (It doesnt have to

Could you create a UML flowchart for the following code, Preferably in the software DIA or Microsoft Word whichever is easier. (It doesnt have to be very specific).

Examples of the UML im looking for (this is not related to the question its just an example)

image text in transcribed

Here is the code and classes for the UML flowchatrt that I need. All I really need is flowchart part as shown in the example above.

image text in transcribed

/** FuelGauge class */

public class FuelGauge

{

// Constant for the maximum number of gallons

static final int MAX_GALLONS = 15;

// Field for the amount of fuel, in gallons

private int gallons;

/**

No-arg constructor

*/

public FuelGauge()

{

gallons = 0;

}

/**

Constructor

@param g The initial number of gallons.

*/

public FuelGauge(int g)

{

// Set gallons to g, but no more than

// the maximum amount.

if (g

gallons = g;

else

gallons = MAX_GALLONS;

}

/**

getGallons method

@return The number of gallons of fuel.

*/

public int getGallons()

{

return gallons;

}

/**

The incrementGallons method increments

the value of gallons. If gallons exceeds

the maximum amount, a message is displayed

incicating the fuel is overflowing.

*/

public void incrementGallons()

{

if (gallons

gallons++;

else

System.out.println("FUEL OVERFLOWING!!!");

}

/**

The decrementGallons method decrements

the value of gallons. If gallons is at 0

then a message is displayed indicating we

are out of fuel.

*/

public void decrementGallons()

{

if (gallons > 0)

gallons--;

else

System.out.println("OUT OF FUEL!!!");

}

}

/**

Odometer class

*/

public class Odometer

{

// Constant for the maximum mileage

static final int MAX_MILEAGE = 999999;

// Constant for the miles-per-gallon

static final int MPG = 24;

// Field for the current mileage

private int mileage;

// Field for the mileage set-point to

// remember when the FuelGuage gallons

// were decremented.

private int setPoint;

// Field to reference a FuelGauge object

private FuelGauge fuelGauge;

/**

Constructor

@param m Initial mileage.

@param fg A reference to a FuelGauge object.

*/

public Odometer(int m, FuelGauge fg)

{

mileage = m;

setPoint = m;

fuelGauge = fg;

}

/**

getMileage method

@return The mileage.

*/

public int getMileage()

{

return mileage;

}

/**

The incrementMileage method increments

the mileage field. If mileage exceeds the

maximum amount, it rolls over to 0.

*/

public void incrementMileage()

{

// Increment the mileage, but rollover

// if we go past the maximum amount.

if (mileage

mileage++;

else

mileage = 0;

// See if we have burned a gallon of gas. This

// happens every MPG miles.

//

// If setPoint is greater than mileage, then

// the odometer has rolled over.

if (setPoint > mileage)

{

// Add MAX_MILEAGE + 1 to get the actual mileage.

int falseMileage = mileage + MAX_MILEAGE + 1;

if ( (falseMileage - setPoint) >= MPG )

{

fuelGauge.decrementGallons();

setPoint = mileage;

}

}

else

{

if ( (mileage - setPoint) >= MPG )

{

fuelGauge.decrementGallons();

setPoint = mileage;

}

}

}

}

/**

Car Instrument Simulator

*/

public class TestCarInstrument

{

public static void main(String[] args)

{

// Create a FuelGuage object.

FuelGauge fuel = new FuelGauge();

// Create an Odometer object to work with the FuelGauge object.

Odometer odometer = new Odometer(0, fuel);

// Fill the car up with gas.

for (int i = 0; i

fuel.incrementGallons();

// Drive the car until it runs out of gas.

while (fuel.getGallons() > 0)

{

// Drive a mile.

odometer.incrementMileage();

// Display the mileage.

System.out.println("Mileage: " + odometer.getMileage());

// Display the amount of fuel.

System.out.println("Fuel level: " + fuel.getGallons() + " gallons");

System.out.println("------------------------------");

}

}

}

TestResultsDemo :Str process Input): int start TestResults testScore start es tResults (r:int rintGrade() void +getGrade) String output prompt start testScore-processinput) input testScore test Score-r if test Score 60 create TestResults as test.l using testscore return testScore stop true output "Your grade is F" false testScore

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago