This file contains hidden or 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
public class FindSpaces { | |
public static void main (String [] args) { | |
String passCode = ""; | |
passCode = " "; | |
for (int i = 0 ; i < passCode.length(); i++) { | |
if (passCode.charAt(i) == ' ') { | |
System.out.println("Space at " + i); | |
} |
This file contains hidden or 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
Execute: | |
> SELECT propCode, SUM(lineItemCost) FROM Preventative where SPRIORITY = 'Preventive Maint' group by propCode | |
+ ------------- + ---------------------- + | |
| propCode | SUM(lineItemCost) | |
This file contains hidden or 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
public class NestedLoops { | |
public static void main (String [] args) { | |
int numRows = 2; | |
int numCols = 3; | |
// Note: You'll need to declare more variables | |
/* Your solution goes here */ | |
for (int i = 1 ; i <= numRows; i++) { | |
for(int j = 1 ; j <= numCols; j++) { |
This file contains hidden or 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
public class NestedLoop { | |
public static void main (String [] args) { | |
int userNum = 0; | |
int i = 0; | |
int j = 0; | |
/* Your solution goes here */ | |
for (i = 0; i <= userNum; i++) { | |
for (j = 0; j < i; j++) { | |
System.out.print(" "); |
This file contains hidden or 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
import java.util.Scanner; | |
public class InsectGrowth { | |
public static void main (String [] args) { | |
int numInsects = 0; | |
numInsects = 8; // Must be >= 1 | |
while(numInsects < 100) { | |
System.out.print(numInsects + " "); |
This file contains hidden or 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
import java.util.Scanner; | |
public class GrocerySorter { | |
public enum GroceryItem {GR_APPLES, GR_BANANAS, GR_JUICE, GR_WATER}; | |
public static void main (String [] args) { | |
GroceryItem userItem = GroceryItem.GR_APPLES; | |
/* Your solution goes here */ | |
if (userItem == GroceryItem.GR_APPLES || userItem == GroceryItem.GR_BANANAS) { |
This file contains hidden or 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
import java.util.Scanner; | |
public class SimonSays { | |
public static void main (String [] args) { | |
String simonPattern = ""; | |
String userPattern = ""; | |
int userScore = 0; | |
int i = 0; | |
userScore = 0; |
This file contains hidden or 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
public class StudentScores { | |
public static void main (String [] args) { | |
final int SCORES_SIZE = 4; | |
int[] oldScores = new int[SCORES_SIZE]; | |
int[] newScores = new int[SCORES_SIZE]; | |
int i = 0; | |
oldScores[0] = 10; | |
oldScores[1] = 20; | |
oldScores[2] = 30; |
This file contains hidden or 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
import java.util.Scanner; | |
public class FindMatchValue { | |
public static void main (String [] args) { | |
final int NUM_VALS = 4; | |
int[] userValues = new int[NUM_VALS]; | |
int i = 0; | |
int matchValue = 0; | |
int numMatches = -99; // Assign numMatches with 0 before your for loop |
This file contains hidden or 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
import java.util.Scanner; | |
public class SumOfExcess { | |
public static void main (String [] args) { | |
final int NUM_VALS = 4; | |
int[] testGrades = new int[NUM_VALS]; | |
int i = 0; | |
int sumExtra = -9999; // Assign sumExtra with 0 before your for loop | |
testGrades[0] = 101; |