Subject Computer Science Java Programming

Question

Many gas pumps have display that spin digits (either analog or digital ) while the gas is being pumped into your car's tank. The display's digits change to indicate the amount of gas in the tank and the current price.
Write a program that displays the spinning of the digits. Your GaspumpDisplay class will allow you to create a "gas pump" display with a specified number of display places and will allow specify the highest digit in use . You will simplify a gas pump display by using smaller display of only three digits where the digits are in the limited range of 0-4 inclusive

public class GasPumpDisplay {
publicGasPumpDisplay(int numbeOfPostion){
}
public BooleanhasMoreElement(){
}
private int digit;
private GasPumpDisplay tail;
private int currentDigite;
private static final MAX_DIGIT=4 ;
}

Public class GasPumpTester{
Public static void main (String [] args){
GasPumpDisplay d= new GasPumpDisplay (3);
Output:
000 001 002 003 004 010 011 012 013 014 020 021 022 023 024 030 031 032 033 034 040 041 042 043 044 100 101 102 103 104 110 111 112 113 114 120 121 122 123 124 130 131 132 133 134 140 141 142 143 144 200 201 202 203 204 210 211 212 213 214 220 221 222 223 224 230 231 232 233 234 240 241 242 243 244 300 301 302 303 304 310 311 312 313 314 320 321 322 323 324 330 331 332 333 334 400 401 402 403 404 410 411 412 413 414 420 421 422 423 424 430 431 432 433 434 444

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class GasPumpDisplay {
public GasPumpDisplay(int numberOfPositions){
if(numberOfPositions > 1)
{
tail = new GasPumpDisplay(numberOfPositions-1);
}
position = numberOfPositions;
currentDigit = 0;
}
public boolean hasMoreElement(){
if(currentDigit == MAX_DIGIT && position > 1 && !tail.hasMoreElement())
{
return false;
}
else if(currentDigit == MAX_DIGIT && position == 1)
{
return false;...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Generic Method For Java Arrays
Homework Solution
$20.00
Java
Programming
Coding
Computer Science
Arrays
Items
Generic Method
Integers
WordList
Strings
Testing
Primitive Types
Input
Output
Java Program: True/False Answers
Homework Solution
$30.00
Java
Programming
Computer Science
Lecturer
Weekly Texts
Students
True/False Answers
Scores
Tests
Questions
Validation
Variables
Loops
Conditions
Classes in Java Programming
Homework Solution
$20.00
Java
Programming
Coding
Classes
OOP
Instances
Variables
Constructor
Parameters
Loops
Strings
Integers
Conditions
Statements
Setters
Getters
Error Handling
Java Programming: Stack & Queue
Homework Solution
$40.00
Programming
Java
Coding
Computer Science
Data Sets
Stack
Queue
Matrix
Circular Array
Algorithm
Duplicates
Sequences
Test Files
Random Functions
Mathematicians
Josephus Problem
Statements
Variables
Java Programming Assignment
Homework Solution
$20.00
Java Test Application
Java Programming
Program
3-D Geometric Shape
Java Class
Constructor
Get help from a qualified tutor
Live Chats