Last active
November 1, 2019 12:36
-
-
Save DanCoughlin/2b100a36fdb2b977a9e8744514062817 to your computer and use it in GitHub Desktop.
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
// part a | |
String[][] songs = { | |
{"Come Together", "Something", "Maxwell's Silver Hammer", "Oh! Darling", "Octopus's Garden", "I Want You"}, | |
{"Here Comes the Sun", "Medley", "Her Majesty" } | |
}; | |
for (int i=0; i < songs.length; i++) { | |
System.out.println("Side: " + (i+1)); | |
for (int j=0; j < songs[i].length; j++) { | |
System.out.println(songs[i][j]); | |
} | |
} | |
// part b | |
ArrayList<String> faves = new ArrayList<>(); | |
faves.add("Thinking About You"); | |
faves.add("I Will Wait"); | |
faves.add("Philosophy"); | |
faves.add("Change"); | |
faves.add("All Eyez On Me"); | |
int counter = 0; | |
System.out.println("Enter your 5 favorite songs"); | |
while (counter < 5) { | |
Scanner s = new Scanner(System.in); | |
String song = s.nextLine(); | |
faves.add(song); | |
counter++; | |
} | |
for (String f:faves) { | |
System.out.println(f); | |
} | |
// part d | |
for (int i=0; i < 8; i++) { | |
for (int j=0; j < 4; j++) { | |
System.out.print("^"); | |
} | |
System.out.println(""); | |
} | |
//1.) | |
Scanner s = new Scanner(System.in); | |
Double[][] parkingSpaces = new Double[10][14]; | |
System.out.println("Please enter the base parking price: "); | |
Double parkingCost = s.nextDouble(); | |
for(int i=0; i<10; i++){ | |
for(int j=0; j<7; j++){ | |
parkingSpaces[i][j] = parkingCost + 5; | |
} | |
for(int j=7; j<14; j++){ | |
parkingSpaces[i][j] = parkingCost; | |
} | |
} | |
for(int i=0; i<10; i++){ | |
for(int j=0; j<7; j++){ | |
System.out.printf("%.2f ",parkingSpaces[i][j]); | |
} | |
System.out.print("|| "); | |
for(int j=7; j<14; j++){ | |
System.out.printf("%.2f ",parkingSpaces[i][j]); | |
} | |
System.out.println(""); | |
} | |
//OR | |
for(int i=0; i<10; i++){ | |
for(int j=0; j<14; j++){ | |
if(j<7){ | |
parkingSpaces[i][j] = parkingCost + 5; | |
} | |
else{ | |
parkingSpaces[i][j] = parkingCost; | |
} | |
} | |
} | |
for(int i=0; i<10; i++){ | |
for(int j=0; j<14; j++){ | |
if(j==7){ | |
System.out.print("|| "); | |
System.out.printf("%.2f ",parkingSpaces[i][j]); | |
} | |
else{ | |
System.out.printf("%.2f ",parkingSpaces[i][j]); | |
} | |
} | |
System.out.println(""); | |
} | |
//2.) | |
ArrayList<String> aLString = new ArrayList<>(); | |
aLString.add("piano"); | |
System.out.println(aLString.get(0)); | |
System.out.println(aLString.size()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment