Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Name:
- * Date:
- * Course Number:
- * Course Name:
- * Problem Number:
- * Email:
- * Short Description of the Problem
- */
- import java.util.Scanner;
- public class TemplateForProjects {
- //**********************************************
- private static void process(Scanner sc, String args[]) {
- // Code here is merely a sample
- int x;
- System.out.print("Enter value: ");
- x = sc.nextInt();
- sc.nextLine(); // IMPORTANT!! Reset Scanner
- System.out.println("Processing " + x + " ...");
- }
- //**********************************************
- private static boolean doThisAgain(Scanner sc, String prompt) {
- System.out.print(prompt);
- String doOver = sc.nextLine();
- return doOver.equalsIgnoreCase("Y");
- }
- //**********************************************
- public static void main(String args[]) {
- final String TITLE = "CSC111 Project Template";
- final String CONTINUE_PROMPT = "Do this again? [y/N] ";
- System.out.println("Welcome to " + TITLE);
- Scanner sc = new Scanner(System.in);
- do {
- process(sc, args);
- } while (doThisAgain(sc, CONTINUE_PROMPT));
- sc.close();
- System.out.println("Thank you for using " + TITLE);
- }
- }
Add Comment
Please, Sign In to add comment