Skip to content

Instantly share code, notes, and snippets.

@bytecodeman
Last active December 11, 2023 01:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bytecodeman/dd09f0757d77088b47e4001c5b7ce09b to your computer and use it in GitHub Desktop.
Save bytecodeman/dd09f0757d77088b47e4001c5b7ce09b to your computer and use it in GitHub Desktop.
Template For Java Homework and Projects
/*
* Name:
* Date:
* Course Number:
* Course Name:
* Problem Number:
* Email:
* Short Description of the Problem
*/
import java.util.Scanner;
public class TemplateForProjects {
private final static String TITLE = "CSC111 Project Template";
private final static String CONTINUE_PROMPT = "Do this again? [y/N] ";
//**********************************************
// Put as many methods you need here
//**********************************************
// Start your logic coding in the process method
private static void process(Scanner input, String args[]) throws Exception {
// Following code is merely a sample, delete it
System.out.print("Enter value: ");
int x = input.nextInt();
System.out.println("Processing " + x + " ...");
input.nextLine(); // Clear the Keyboard
}
//**********************************************
// Do not change the doThisAgain method
private static boolean doThisAgain(Scanner input, String prompt) {
System.out.print(prompt);
String doOver = input.nextLine();
return doOver.trim().equalsIgnoreCase("Y");
}
//**********************************************
// Do not change the main method
public static void main(String args[]) throws Exception {
System.out.println("Welcome to " + TITLE);
Scanner input = new Scanner(System.in);
do {
process(input, args);
} while (doThisAgain(input, CONTINUE_PROMPT));
input.close();
System.out.println("Thank you for using " + TITLE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment