Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment 17 loops #30

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
17 changes: 8 additions & 9 deletions foundation/12-syntax/src/com/bloc/syntax/SyntaxDisaster.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

package com.bloc.syntax;

public class SyntaxDisaster extends Object {
Expand All @@ -8,17 +7,17 @@ public class SyntaxDisaster extends Object {
* Fix the code found below this block
/************************************************/

public static void main(String [] args) {;}
if (true); {
int x = 5
public static void main(String [] args) {
if (true) {
int x = 5;
}
int syntaxIsFun; 5;
/* The following line prints stuff out, I promise
System.out.println("If you can see this message, you've won!);
}
int syntaxIsFun = 5;
/*The following line prints stuff out, I promise*/

System.out.println("If you can see this message, you've won!");
}
/************************************************
* ASSIGNMENT:
* Fix the code found above this block
/************************************************/
}
}
Binary file not shown.
Binary file not shown.
15 changes: 9 additions & 6 deletions foundation/15-operations/src/com/bloc/ops/Operations.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,46 @@ public static void main(String [] args) {
* Place 18 into x
/************************************************/

int x;
int x = 18;

/************************************************
* ASSIGNMENT:
* Pre-increment x and assign it to y in a single statement
/************************************************/

int y;
int y = ++x;

/************************************************
* ASSIGNMENT:
* Multiply x by y, assign it to z
/************************************************/

int z;
int z = (x*y);

/************************************************
* ASSIGNMENT:
* Mod z by 17 and assign the result to remainder
/************************************************/

int remainder;
int remainder = z % 17;

/************************************************
* ASSIGNMENT:
* Assign 5 to floaty and then divide it by 3
/************************************************/

float floaty;
float floaty = 5;
floaty = floaty / 3;


/************************************************
* ASSIGNMENT:
* Assign 5.3 into dubs
* Then multiply dubs by itself
/************************************************/

double dubs;
double dubs = 5.3;
dubs = dubs * dubs;

/************************************************
* DO NOT MODIFY BELOW THIS CALLOUT
Expand Down
Binary file not shown.
10 changes: 5 additions & 5 deletions foundation/16-logic/src/com/bloc/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static void main(String [] args) {
* that the statement evaluates to 'true'
/************************************************/

if (false && true) { // Change something here
if (true && true) { // Change something here
buffer.append("r");
} else {
buffer.append("w");
Expand All @@ -32,7 +32,7 @@ public static void main(String [] args) {

int x = 5; // Change here
int y = 10; // Or here
int z = 30; // Or here
int z = 83; // Or here
if (x == 6 || y == 11 || z == 83) { // Or even here, who knows
buffer.append("i");
} else {
Expand All @@ -46,7 +46,7 @@ public static void main(String [] args) {
/************************************************/

boolean aSincereFalsehood = false;
if (aSincereFalsehood) { // Add an operator to this line
if (aSincereFalsehood = true) { // Add an operator to this line
buffer.append("g");
} else {
buffer.append("o");
Expand All @@ -58,7 +58,7 @@ public static void main(String [] args) {
* statement to evaluate as 'true'
/************************************************/

if (200 > 200) {
if (200 == 200) {
buffer.append("h");
} else {
buffer.append("n");
Expand All @@ -72,7 +72,7 @@ public static void main(String [] args) {
/************************************************/

boolean lastOne = false;
if ((8 < 0) && !(15 == 15) && (lastOne == true)) { // Modify this line
if ((8 > 0) && (15 == 15) && (lastOne == false)) { // Modify this line
buffer.append("t");
} else {
buffer.append("g");
Expand Down
Binary file not shown.
70 changes: 49 additions & 21 deletions foundation/17-loops/src/com/bloc/loops/Loops.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,42 @@ public static void main(String [] args) {
boolean temp = false;

//********** Starts Here ************************/
temp = someBools[7];
someBools[7] = someBools[0];
someBools[0] = temp;

temp = someBools[6];
someBools[6] = someBools[1];
someBools[1] = temp;
//int i = 0;
//while (i < 8) {
// temp = someBools[i];
// System.out.println(temp);
// i++;
//}

temp = someBools[5];
someBools[5] = someBools[2];
someBools[2] = temp;

temp = someBools[4];
someBools[4] = someBools[3];
someBools[3] = temp;

// temp = someBools[7];
// someBools[7] = someBools[0];
// someBools[0] = temp;

// temp = someBools[6];
// someBools[6] = someBools[1];
// someBools[1] = temp;

// temp = someBools[5];
// someBools[5] = someBools[2];
// someBools[2] = temp;

// temp = someBools[4];
// someBools[4] = someBools[3];
// someBools[3] = temp;


int position = 0;
int i = someBools.length - 1;
while (i >= 4) {
temp = someBools[i];
someBools[i] = someBools[position];
someBools[position] = temp;
position++;
i--;
}

//********** Ends Here **************************/


Expand All @@ -49,15 +70,22 @@ public static void main(String [] args) {
* Learn more here: http://www.cafeaulait.org/course/week2/43.html
/************************************************/



//********** Starts Here ************************/
numArray[0] = !someBools[0] ? 1 : 0;
numArray[1] = !someBools[1] ? 1 : 0;
numArray[2] = !someBools[2] ? 1 : 0;
numArray[3] = !someBools[3] ? 1 : 0;
numArray[4] = !someBools[4] ? 1 : 0;
numArray[5] = !someBools[5] ? 1 : 0;
numArray[6] = !someBools[6] ? 1 : 0;
numArray[7] = !someBools[7] ? 1 : 0;
// numArray[0] = !someBools[0] ? 1 : 0;
// numArray[1] = !someBools[1] ? 1 : 0;
// numArray[2] = !someBools[2] ? 1 : 0;
// numArray[3] = !someBools[3] ? 1 : 0;
// numArray[4] = !someBools[4] ? 1 : 0;
// numArray[5] = !someBools[5] ? 1 : 0;
// numArray[6] = !someBools[6] ? 1 : 0;
// numArray[7] = !someBools[7] ? 1 : 0;

for (int j = 0; j < numArray.length; j++) {
numArray[j] = !someBools[j] ? 1 : 0;
}

//********** Ends Here **************************/


Expand Down