In Java Write a Java program that prompts the user to select

In Java, Write a Java program that prompts the user to select an integer value between 1 and 4 that corresponds to a section of President Abraham Lincoln\'s Gettysburg Address. The program will have three methods in addition to main(): intro(), para2(), and para3(). The main() method outputs the prompt, reads in the selections and then calls the appropriate method to output the part(s) of the speech selected. None of these methods returns a value, therefore the call to the method will be a statement rather than an assignment statement. Example: intro(); is a statement that will call the intro() method.

The intro() method outputs

The para2() method outputs the phrase:

The para3() method outputs the phrase:

If the user selects 4, methods intro(), para2(), and para3() will be called in order (with a blank line between paragraphs).

In this format

import java.util.Scanner;

public class Lab6c {
public static void main (String[] args) {
Scanner scnr = new Scanner(System.in);
  
// Prompt user for numeric input
  
/* If input is
* 1 -> print paragraph 1 by calling intro()
* 2 -> print paragraph 2 by calling para2()
* 3 -> print paragraph 3 by calling para3()
* 4 -> print all paragrahs in order 1, 2, 3
*/
  
}

public static void intro() {
// TODO
}

public static void para2() {
// TODO
}

public static void para3() {
// TODO
}

public static void blank() {
// TODO (optional) could just println blank line in main() method
}
}

Solution

Hi, Please find my implementation

Please let me know in case of any issue.

import java.util.Scanner;

public class Lab6c {

   public static void main (String[] args) {

Scanner scnr = new Scanner(System.in);

  

System.out.print(\"Enter a number in range (1-4) ? \" );

int num = scnr.nextInt();

  

blank();

  

if(num == 1){

      intro();

}else if(num == 2){

      para2();

}else if(num == 3){

      para3();

}else if(num == 4){

      intro();

      para2();

      para3();

}

  

/* If input is

   * 1 -> print paragraph 1 by calling intro()

   * 2 -> print paragraph 2 by calling para2()

   * 3 -> print paragraph 3 by calling para3()

   * 4 -> print all paragrahs in order 1, 2, 3

   */

  

   }

   public static void intro() {

   System.out.println(\"Four score and seven years ago our fathers brought forth on this continent a new nation,\"+

                      \"conceived in liberty and dedicated to the proposition that all men are created equal.\");

   }

   public static void para2() {

System.out.println(\"Now we are engaged in a great civil war, testing whether that nation or any nation\"+

                           \"so conceived and so dedicated can long endure. We are met on a great battlefield of\"+

                           \"that war. We have come to dedicate a portion of that field as a final resting-place\"+

                           \"for those who here gave their lives that that nation might live. It is altogether\"+

                           \"fitting and proper that we should do this.\");

  

   }

   public static void para3() {

System.out.println(\"But in a larger sense, we cannot dedicate, we cannot consecrate, we cannot hallow\"+

                           \"this ground. The brave men, living and dead who struggled here have consecrated it\"+

                           \"far above our poor power to add or detract. The world will little note nor long\"+

                           \"remember what we say here, but it can never forget what they did here. It is for us\"+

                           \"the living rather to be dedicated here to the unfinished work which they who fought\"+

                           \"here have thus far so nobly advanced. It is rather for us to be here dedicated to\"+

                           \"the great task remaining before us — that from these honored dead we take increased\"+

                           \"devotion to that cause for which they gave the last full measure of devotion — that\"+

                           \"we here highly resolve that these dead shall not have died in vain, that this nation\"+

                           \"under God shall have a new birth of freedom, and that government of the people, by\"+

                           \"the people, for the people shall not perish from the earth.\");

  

   }

   public static void blank() {

System.out.println(); // blank line

   }

}

/*

Sample output:

Enter a number in range (1-4) ? 3

But in a larger sense, we cannot dedicate, we cannot consecrate, we cannot hallowthis ground. The brave men, living and dead who struggled here have consecrated itfar above our poor power to add or detract. The world will little note nor longremember what we say here, but it can never forget what they did here. It is for usthe living rather to be dedicated here to the unfinished work which they who foughthere have thus far so nobly advanced. It is rather for us to be here dedicated tothe great task remaining before us — that from these honored dead we take increaseddevotion to that cause for which they gave the last full measure of devotion — thatwe here highly resolve that these dead shall not have died in vain, that this nationunder God shall have a new birth of freedom, and that government of the people, bythe people, for the people shall not perish from the earth.

*/

In Java, Write a Java program that prompts the user to select an integer value between 1 and 4 that corresponds to a section of President Abraham Lincoln\'s Get
In Java, Write a Java program that prompts the user to select an integer value between 1 and 4 that corresponds to a section of President Abraham Lincoln\'s Get
In Java, Write a Java program that prompts the user to select an integer value between 1 and 4 that corresponds to a section of President Abraham Lincoln\'s Get

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site