The following Java program prompts the user and reads in a line

Added on - 16 Sep 2019

  • 3

    pages

  • 489

    words

  • 102

    views

  • 0

    downloads

Showing pages 1 to 1 of 3 pages
The following Java program prompts the user and reads in a line of text, then displays the text. Theclass name is A9. You should not change the class name./*** A simple program that prompts the user* for a line of text.*/import java.util.Scanner;public class A9 {public static String getPhrase () {Scanner input = new Scanner(System.in);System.out.print ("Enter a phrase: ");String phrase = input.nextLine();return phrase;}public static void reportPhrase (String phrase) {System.out.println (phrase);}public static void printHistogram (String phrase) {// Your code here}public static void main(String args[]) {String phrase;phrase = getPhrase ();reportPhrase (phrase);
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Unlock This Document