-
-
Save bytecodeman/83671ada96170005fe6843bedd59abb8 to your computer and use it in GitHub Desktop.
CSC-111 Array In class Challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Name: | |
* Date: | |
* Course Number: | |
* Course Name: | |
* Problem Number: | |
* Email: | |
* Short Description of the Problem | |
*/ | |
import java.util.Scanner; | |
public class FindMinApp { | |
private static int[] readIntegers(Scanner input, int count) { | |
int[] array = new int[count]; | |
for (int i = 0; i < array.length; i++) { | |
System.out.println("Enter a number:"); | |
int number = input.nextInt(); | |
array[i] = number; | |
} | |
return array; | |
} | |
private static int findMin(int[] array) { | |
return -99999; | |
} | |
//********************************************** | |
private static void process(Scanner sc, String args[]) { | |
System.out.println("Enter count:"); | |
int count = sc.nextInt(); | |
int[] returnedArray = readIntegers(sc, count); | |
sc.nextLine(); // Clears Keyboard | |
int returnedMin = findMin(returnedArray); | |
System.out.println("min = " + returnedMin); | |
} | |
//********************************************** | |
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment