Please take look at this java code and help me complete this code to compile together.    //MainValidatorA3 public class MainA3 {     public static void main(String[] args) {         System.out.println("Welcome to the Validation Tester application");         // Int Test         System.out.println("Int Test");         ValidatorNumeric intValidator = new ValidatorNumeric("Enter an integer between -100 and 100: ", -100, 100);         int num = intValidator.getIntWithinRange();         System.out.println("You entered: " + num + "\n");         // Double Test         System.out.println("Double Test");         ValidatorNumeric doubleValidator = new ValidatorNumeric("Enter a double value: ");         double dbl = doubleValidator.getDoubleWithinRange();         System.out.println("You entered: " + dbl + "\n");         // Required String Test         System.out.println("Required String Test:");         ValidatorString stringValidator = new ValidatorString("Enter a required string: ");         String requiredString = stringValidator.getRequiredString();         System.out.println("\nYou entered: " + requiredString + "\n");         // String Choice Test         System.out.println("String Choice Test");         ValidatorString choiceValidator = new ValidatorString("Select one (x/y): ", "x", "y");         String choice = choiceValidator.getChoiceString();         System.out.println("You entered: " + choice);         System.out.println("\nAll Done!");     } }   // Validator.java import java.util.Scanner; public interface Validator {     String getRequiredString();     String getChoiceString(); }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please take look at this java code and help me complete this code to compile together. 

 

//MainValidatorA3

public class MainA3 {
    public static void main(String[] args) {
        System.out.println("Welcome to the Validation Tester application");

        // Int Test
        System.out.println("Int Test");
        ValidatorNumeric intValidator = new ValidatorNumeric("Enter an integer between -100 and 100: ", -100, 100);
        int num = intValidator.getIntWithinRange();
        System.out.println("You entered: " + num + "\n");

        // Double Test
        System.out.println("Double Test");
        ValidatorNumeric doubleValidator = new ValidatorNumeric("Enter a double value: ");
        double dbl = doubleValidator.getDoubleWithinRange();
        System.out.println("You entered: " + dbl + "\n");

        // Required String Test
        System.out.println("Required String Test:");
        ValidatorString stringValidator = new ValidatorString("Enter a required string: ");
        String requiredString = stringValidator.getRequiredString();
        System.out.println("\nYou entered: " + requiredString + "\n");

        // String Choice Test
        System.out.println("String Choice Test");
        ValidatorString choiceValidator = new ValidatorString("Select one (x/y): ", "x", "y");
        String choice = choiceValidator.getChoiceString();
        System.out.println("You entered: " + choice);

        System.out.println("\nAll Done!");
    }
}

 

// Validator.java

import java.util.Scanner;

public interface Validator {
    String getRequiredString();
    String getChoiceString();
}

 

// ValidatorNumeric.java
import java.util.Scanner;
public class ValidatorNumeric implements Validator {
private String prompt;
private int minInt, maxInt;
private double minDouble, maxDouble;
public ValidatorNumeric() {
-
public ValidatorNumeric (String prompt, int min, int max) {
this.prompt = prompt;
this.minInt = min;
this.maxInt = max;
public ValidatorNumeric (String prompt, double min, double max) {
}
this.prompt = prompt;
this.minDouble = min;
this.maxDouble = max;
D
@Override
public String getRequiredString()
{
// Implementing the interface method, but not used for numeric validators
return null;
-
@Override
public String getChoiceString()
}
{
// Implementing the interface method, but not used for numeric validators
return null;
D
public int getInt() {
Scanner scanner = new Scanner (source: System.in);
System.out.print (s: prompt);
while (!scanner.hasNextInt()) {
}
System.out.println(x: "Error! Invalid integer value. Try again.");
System.out.print (s: prompt);
scanner.next();
return scanner.nextInt();
-
public int getIntWithinRange () {
Transcribed Image Text:// ValidatorNumeric.java import java.util.Scanner; public class ValidatorNumeric implements Validator { private String prompt; private int minInt, maxInt; private double minDouble, maxDouble; public ValidatorNumeric() { - public ValidatorNumeric (String prompt, int min, int max) { this.prompt = prompt; this.minInt = min; this.maxInt = max; public ValidatorNumeric (String prompt, double min, double max) { } this.prompt = prompt; this.minDouble = min; this.maxDouble = max; D @Override public String getRequiredString() { // Implementing the interface method, but not used for numeric validators return null; - @Override public String getChoiceString() } { // Implementing the interface method, but not used for numeric validators return null; D public int getInt() { Scanner scanner = new Scanner (source: System.in); System.out.print (s: prompt); while (!scanner.hasNextInt()) { } System.out.println(x: "Error! Invalid integer value. Try again."); System.out.print (s: prompt); scanner.next(); return scanner.nextInt(); - public int getIntWithinRange () {
public int getIntWithinRange () {
}
int num;
do {
num
getInt();
if (num <minInt) {
System.out.println("Error! Number must be greater than " + (minInt - 1));
}else if (num > maxInt) {
}
System.out.println("Error! Number must be less than " + (maxInt + 1));
} while (num < minInt || num > maxInt);
return num;
public double getDouble() {
Scanner scanner = new Scanner (source: System.in);
System.out.print (s: prompt);
while (!scanner.hasNextDouble () ) {
}
System.out.println(x: "Error! Invalid decimal value. Try again.");
System.out.print(s: prompt);
scanner.next();
return scanner.nextDouble();
}
public double getDoubleWithinRange () {
double num;
do {
num = getDouble();
if (num <minDouble) {
System.out.println("Error! Number must be greater than " + minDouble);
}else if (num > maxDouble) {
}
System.out.println("Error! Number must be less than " + maxDouble);
} while (num < minDouble || num > maxDouble);
return num;
Transcribed Image Text:public int getIntWithinRange () { } int num; do { num getInt(); if (num <minInt) { System.out.println("Error! Number must be greater than " + (minInt - 1)); }else if (num > maxInt) { } System.out.println("Error! Number must be less than " + (maxInt + 1)); } while (num < minInt || num > maxInt); return num; public double getDouble() { Scanner scanner = new Scanner (source: System.in); System.out.print (s: prompt); while (!scanner.hasNextDouble () ) { } System.out.println(x: "Error! Invalid decimal value. Try again."); System.out.print(s: prompt); scanner.next(); return scanner.nextDouble(); } public double getDoubleWithinRange () { double num; do { num = getDouble(); if (num <minDouble) { System.out.println("Error! Number must be greater than " + minDouble); }else if (num > maxDouble) { } System.out.println("Error! Number must be less than " + maxDouble); } while (num < minDouble || num > maxDouble); return num;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Adjacency Matrix
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.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education