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

Added on - 16 Sep 2019

  • 3

    Pages

  • 489

    Words

  • 255

    Views

  • 0

    Downloads

Trusted by +2 million users,
1000+ happy students everyday
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
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document