Question: In Java using code below! import java.util.Scanner; public class Validation { public static void main(String ar[]) { System.out.println(Validation by me); Scanner in = new Scanner(System.in);

In Java using code below!

In Java using code below! import java.util.Scanner; public class Validation { public

import java.util.Scanner;

public class Validation {

public static void main(String ar[])

{

System.out.println("Validation by me");

Scanner in = new Scanner(System.in);

String prompt = "Enter your name";

int maxLength = 20;

Validation.getString(in, prompt, maxLength);

prompt = "Enter your age: ";

int lower = 0;

int upper = 80;

Validation.getInteger(in, prompt, lower, upper);

}

public static String getString(Scanner in, String prompt, int maxLength)

{

boolean valid = true;

String s = "";

System.out.print(prompt);

System.out.print(" : ");

do

{

s = in.nextLine();

if (s.length() > 0) // ignore blank lines

{

if (s.length()

{

valid = true;

}

else

{

System.out.printf("Minimum length is %d characters. Try again.");

}

}

} while(!valid);

return s;

}

public static int GetInteger(Scanner in, String prompt, int lower, int upper)

{

boolean valid = false, outOfRange = false;

int input = -1;

do

{

System.out.print(prompt);

if (outOfRange) System.out.printf(" [between %d and %d inclusive]", lower, upper);

System.out.print(": ");

while (in.hasNextInt())

{

in.nextDouble();

System.out.println("Please enter an integer.");

}

input = in.nextInt();

if (input >= 0 && input

{

valid = true;

}

else

{

System.out.println("Value is out of range.");

outOfRange = true;

}

} while (!valid);

return input;

}

}

create a class called "HistogramGenerator" Create a program (in the main() method) to generate a histogram, based on the following input form the user: Title Number of items Each item, followed by the value. Your program should function like the following storyboards "Happy" Path Histogram Generator by Joe Student Enter the histogram title:Favorite Languages Students Enter the number of items: 3 Enter item 1 Java Enter value 1: 14 Enter item 2 C++ Enter value 2: 7 Enter item 3 JavaScript Enter value 3: 4 Favorite Languages of programming Students Java JavaScript @@@a No Data Histogram Generator by Joe Student Enter the histogram title: An empty histogram Enter the number of items: 0 An empty histogram

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!