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

Feedback #1

Open
wants to merge 15 commits into
base: feedback
Choose a base branch
from
16 changes: 8 additions & 8 deletions 01-leap-year/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,40 @@
} // end inner if statement
} // end outer if statement
```
* **YOUR WRITING HERE**
* incorrect


2. Label each as either correct or incorrect syntax. If incorrect, rewrite below:
* if (x == y) {

* **YOUR WRITING HERE**
* correct

* if [x == 10] {

* **YOUR WRITING HERE**
* incorrect

* if x = 10 then {

* **YOUR WRITING HERE**
* incorrect

* if (x equals 42) {

* **YOUR WRITING HERE**
* incorrect

* if (x => y) {

* **YOUR WRITING HERE**
* incorrect


3. Fix the error in the code below:

```
Scanner console = new Scanner(System.in);
System.out.print("What is your favorite color? ");
String name = console.next();
String name = console.next();-------------------------> its suppose to be console.nextLine();
if (name == "blue") {
    System.out.println("Mine, too!");
}
```

* **YOUR WRITING HERE**
* incorrect
37 changes: 37 additions & 0 deletions 01-leap-year/leap year
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import java.util.Scanner;
class Main {
public static void main(String[] args) {
System.out.println("Leap year checker!");
Scanner i = new Scanner(System.in);
int x;
System.out.println("Enter your user: ");
String user =i.nextLine();
System.out.println("Enter a year: ");
x = i.nextInt();
System.out.println(user+" the year "+ x+" is "+leapYear(x));
System.out.println(user+" the year "+leapYear(2022));
System.out.println(user+" the year "+leapYear(2024));
System.out.println(user+" the year "+leapYear(2000));
System.out.println(user+" the year "+leapYear(1900));
}

public static boolean leapYear(int x) {
if (x % 100==0){
return true;
}
else if (x %400==0){
return true;
}
else if (x %4==0){
return false;
}
else{
return false;
}
}



}


18 changes: 9 additions & 9 deletions 02-fizzbuzz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@

| P | Q | P && Q | P \|\| Q |
|:--:|:--:|:------:|:--------:|
| T | T | | |
| T | F | | |
| F | T | | |
| F | F | | |
| T | T | T | T |
| T | F | T | F |
| F | T | T | F |
| F | F | F | F |


2. Prove a version of DeMorgan's Law:

| P | Q | P \|\| Q | ! (P \|\| Q) | !P | !Q | !P && !Q |
|:--:|:--:|:--------:|:------------:|:--:|:--:|:--------:|
| T | T | | | | | |
| T | F | | | | | |
| F | T | | | | | |
| F | F | | | | | |
| T | T | T | F | F | F | F |
| T | F | F | T | F | T | F |
| F | T | F | T | T | F | F |
| F | F | F | T | T | T | T |

3. What does DeMorgan's state and how did you prove it for the case above?
* **YOUR WRITING HERE**
* demorgan's law helps make the program simpler and faster and uses logical statements to determine if its true or false and in the demorgan's law table it shows you different results if your using !.
41 changes: 41 additions & 0 deletions 02-fizzbuzz/fizz buzz
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import java.util.Scanner;
class Main{
public static void main(String args[]){

Scanner j = new Scanner(System.in);

System.out.println("Enter a number: ");

final String re = "\u001B[0m";

final String y = "\u001B[33m";

final String b = "\u001B[34m";

final String p = "\u001B[35m";



int x = j.nextInt();

System.out.println();

for (int i = 1; i <= x; i++){
if (i%3==0 && i%5==0){
System.out.println(y+"FizzBuzz"+re);
}
else if (i%3==0){
System.out.println(b+"Fizz"+re);
}
else if (i%5==0){
System.out.println(p+"Buzz"+re);
}
else{
System.out.println(i);

}
j.close();
}
}

}
2 changes: 1 addition & 1 deletion 03-count-quarters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#### Respond to the following:

1. How do you isolate the ones digit of a number?
* **YOUR WRITING HERE**
* you first have to know the length-2 and use substring then convert it to string then divide by 25 and return it
26 changes: 26 additions & 0 deletions 03-count-quarters/count quarters
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner i = new Scanner(System.in);
int cents;
System.out.println("Enter your user: ");
String user =i.nextLine();
System.out.println("Enter a number: ");
cents = i.nextInt();
System.out.println(user+" the value is "+sub(cents));
}



public static int sub(int cents){
String c = Integer.toString(cents);

if (c.length()<2){
return 0;
}
String r = c.substring(c.length()-2);
int r1 = Integer.valueOf(r);
int noq = r1/25;
return noq;
}
}
2 changes: 1 addition & 1 deletion 04-letter-grade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


2. Discuss how you would make sure 100 is not misrepresented as an A-.
* **YOUR WRITING HERE**
* you just say that if grade is <= to 100 then print A+.


3. Discuss how you would make sure grades that are an F are not mislabeled as F- or F+ (eg: 49 -> F+ and 52 -> F-)
Expand Down
36 changes: 36 additions & 0 deletions 04-letter-grade/grade letter
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner i = new Scanner(System.in);
int g;
System.out.println("Enter your student name: ");
String user =i.nextLine();
System.out.println("Enter a your grade: ");
g = i.nextInt();
System.out.println("your letter grade is "+letter(g));


}

// getNumericGrade method to return grade number
public static String letter(int g) {
String l="";
if(g>=100) {
l+="A+";
} else if(g>=90) {
l+="A";
} else if(g==89||g>=80) {
l+="B";
} else if(g==79||g>=70) {
l+="C";
} else if(g==69||g>65) {
l+="D";
} else if(g==64||g>=1) {
l+="F";
} else {
System.out.println("Invalid letter grade");
}

return l;
}
}
2 changes: 1 addition & 1 deletion 05-div-by-3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Outline an algorithm to determine whether or not a number is prime.
Think of the following method header:
`public static boolean isPrime(int num)`

* **YOUR WRITING HERE**
* if the number is <= 1 then return false otherwise return true.
28 changes: 28 additions & 0 deletions 05-div-by-3/divisible by 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner i = new Scanner(System.in);
int n;
int sum=0;
System.out.println("Enter your user: ");
String user =i.nextLine();
System.out.println("Enter a number: ");
n = i.nextInt();
System.out.println(user+" the output is "+d(n,sum));
}

public static boolean d(int n,int sum){
while (sum==0) {
int digit = n % 10;
sum += digit;
n /= 10;
if(sum%3==0){
return true;
}
}
return false;
}


}

90 changes: 90 additions & 0 deletions 06-shapes/shapes
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner i = new Scanner(System.in);
int l;
int w;
int h;
int r;
double d;
int ss;
System.out.println("Enter square/rectangle,rtriangle,triangle, or circle: ");
String e=i.nextLine();
if (e.equals("rtriangle")){
System.out.println("Enter a symbol: ");
String c=i.nextLine();
System.out.println("Enter a number for height: ");
h=i.nextInt();
rtriangle(h, c);
}
else if (e.equals("triangle")){
System.out.println("Enter a symbol: ");
String c=i.nextLine();
System.out.println("Enter a number for the spacing: ");
ss=i.nextInt();
triangle(ss, c);
}
else if (e.equals("circle")){
System.out.println("Enter a symbol: ");
String c=i.nextLine();
System.out.println("Enter a number for radius: ");
r=i.nextInt();
for(int rr=0;rr<=2 * r; rr++)
{
for(int s=0; s<=2*r; s++)
{
d = Math.sqrt((rr-r) * (rr-r)+ (s-r) * (s-r));
if(d > r-0.5 && d < r+0.5)
System.out.print(c);
else
System.out.print(" ");
}
System.out.println();
//Prints a newline
}
}
else{
System.out.println("Enter a symbol: ");
String c=i.nextLine();
System.out.println("Enter a number for row: ");
l=i.nextInt();
System.out.println("Enter a number for column: ");
w= i.nextInt();

reactangle(l, w, c);
}
}
public static void reactangle(int l,int w, String c){
for(int row=0; row<l; row++){
for(int col=0; col<w; col++){
System.out.print(" "+c+" ");
}
System.out.println();
}
}

public static void triangle(int ss, String c) {
for(int i=1;i<=10;i++){
for(int j=1;j<=ss-i;j++){
System.out.print(" ");
}
for(int j=1;j<=2*i-1;j++){
System.out.print(c);
}
System.out.println();
}

}

public static void rtriangle(int h, String c){
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(c+" ");
}
System.out.println();
}
}


}

Loading