Hack 1.1

Print your name and your team name in separate lines!

public class Printing {

    public static void main(String args[]) {
        System.out.println("Evan Sanchez");
        System.out.println("Team 10");
    }
}

Printing.main(null);
Evan Sanchez
Team 10

Hack 1.2

Create variables for your biodata (name, age, underclassmen or not, height in feet)

public class Biodata {

    public static void main(String[] args) {
        
        String name = "Evan";
        int age = 17;
        boolean underclassmen = false;
        double height = 5.75;

    }
}

Biodata.main(null);

Hack 1.3

  • Compute the remainder of 6 multiplied by 1234124 divided by 11345 minus 890809 plus 90800 (use order of operations) is divided by 980098, and store this in a variable called num (get an exact number as opposed to a whole number)
  • Divide num by 100
  • Print num
public class Num {

    public static void main(String[] args) {

        int num = ((6 * 1234124 / 11345 - 890809 + 90800) % 980098);
        System.out.println(num);
        System.out.println(num/100);
    }
}

Num.main(null);
-799357
-7993

Hack 1.4

  • Create a code which performs mathmatical calculations with assignment operators!
public class math {

    public static void main(String args[]) {

        int a = 4;
        int b = 5;
        int c = 2;

        a += b;
        c *= a;
        System.out.println(c);
    }
}

math.main(null);
18

Hack 1.5

  • Convert 123456.123456 into an integer
  • Set 678901234567890 into an integer (what do you think will happen?)
public class conversion {

    public static void main(String args[]) {

        double a = 123456.123456;
        int b = (int) a;
        System.out.println(b);

        // this integer is too large and will create an error
        //int c = 678901234567890; 
    }
}

conversion.main(null);
123456

Homework

import java.util.Scanner;

public class gradeCalc {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("Is your final in an individual category? (t/f)");
        boolean testCat = sc.nextBoolean(); 

        if (testCat == true) {

            //current grade
            System.out.println("What is your current grade?");  
            float currentGrade = sc.nextInt();
            currentGrade /= 100; 

            //percentage of final
            System.out.println("What percentage of your grade is the final?"); 
            float percentOfGrade = sc.nextInt();
            percentOfGrade /= 100; 

            //desired grade
            System.out.println("What grade do you plan to finish with?");
            float desiredGrade = sc.nextInt();
            desiredGrade /= 100;

            //grade needed calculation 
            float gradeNeeded = ((desiredGrade - ((1 - percentOfGrade)* currentGrade)) / percentOfGrade) * 100;
            System.out.println("You need a " + gradeNeeded + "%");
        } 
        else {
            System.out.println("No score inputed.");
        }  


    }
    

}

gradeCalc.main(null);
Is your final in an individual category? (t/f)
What is your current grade?
What percentage of your grade is the final?
What grade do you plan to finish with?
You need a -493.99997%