Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can som one correct the errors in the below program: Q) Many gas pumps have displays that spin digits (either analog or digital) while the

can som one correct the errors in the below program:

Q)

Many gas pumps have displays that spin digits (either analog or digital) while the gas is being pumped into your cars gas tank. The displays 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 you to specify the highest digit in use. You will simplify a gas pump display by using a smaller display of only three digits where the digits are in the limited range of

0 4 inclusive.

public class GasPumpDisplay{

public GasPumpDisplay (int numberOfPosition){

}

public String nextElement (){

}

public Boolean hasMoreElements (){

}

private int digits;

private GasPumpDisplay tail;

private int currentDigit;

private static final MAX_DIGIT=4;

}

public class GasPumpTester{

public static void main (String [ ] args){

GasPumpDisplay d = new GasPumpDislay (3);

}

}

Output: GasPumpTester prints the following permutations.

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 340 341 342 343 344

400 401 402 403 404 410 411 412 413 414 420 421 422 423 424 430 431 432 433 434

440 441 442 443 444

Program:

package day1.examples;

import java.util.*;

public class GasPumpDisplay { public static void GasPumpDisplay(String[] digits, List gas, String places, int highDigit){ if (places.length() >= highDigit) return; for (String s :digits) { String str=places+s; gas.add(str); GasPumpDisplay(digits, gas, str, highDigit); } for (int i=0; i

public static void main(String[] args) { String[] range = {"0", "1", "2", "3", "4"}; ArrayList gasPump = new ArrayList(); GasPumpDisplay (range, gasPump, "", 3); System.out.println(gasPump); } }

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_2

Step: 3

blur-text-image_3

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago