Guest User

CSC-220 Project Template

a guest
Sep 8th, 2016
692
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. /*
  2.  * Name:
  3.  * Date:
  4.  * Course Number:
  5.  * Course Name:
  6.  * Problem Number:
  7.  * Email:
  8.  * Short Description of the Problem
  9.  */
  10.  
  11. import java.util.Scanner;
  12.  
  13. public class TemplateForProjects {
  14.    
  15.    
  16.     //**********************************************
  17.    
  18.     private static void process(Scanner sc, String args[]) {
  19.         // Code here is merely a sample
  20.         int x;
  21.         System.out.print("Enter value: ");
  22.         x = sc.nextInt();
  23.         sc.nextLine();  // IMPORTANT!! Reset Scanner
  24.         System.out.println("Processing " + x + " ...");
  25.     }
  26.    
  27.     //**********************************************
  28.    
  29.     private static boolean doThisAgain(Scanner sc, String prompt) {
  30.         System.out.print(prompt);
  31.         String doOver = sc.nextLine();
  32.         return doOver.equalsIgnoreCase("Y");
  33.     }
  34.    
  35.     //**********************************************
  36.    
  37.     public static void main(String args[]) {
  38.         final String TITLE = "CSC111 Project Template";
  39.         final String CONTINUE_PROMPT = "Do this again? [y/N] ";
  40.        
  41.         System.out.println("Welcome to " + TITLE);
  42.         Scanner sc = new Scanner(System.in);
  43.         do {
  44.             process(sc, args);
  45.         } while (doThisAgain(sc, CONTINUE_PROMPT));
  46.         sc.close();
  47.         System.out.println("Thank you for using " + TITLE);
  48.     }
  49.  
  50. }
Add Comment
Please, Sign In to add comment