Old Exam studying stuff
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.mycompany.mavenproject1;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class BitwiseOR {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int x = 1;
|
||||
int y = 5;
|
||||
while (y-- > 0 ^ x++ < 100);
|
||||
System.out.println(++x);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,6 @@ public class ByteOverFlow {
|
||||
{
|
||||
byte b = 127;
|
||||
b++;
|
||||
System.out.println(b);
|
||||
System.out.println(b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,14 @@ package com.mycompany.mavenproject1;
|
||||
* @author caleb
|
||||
*/
|
||||
public class Loop12 {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
for (int j = 0; j < i; j += 2)
|
||||
System.out.println("java");
|
||||
|
||||
public static void main(String[] args) {
|
||||
int lol = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
for (int j = 0; j < i; j += 2) {
|
||||
System.out.println("java" + ++lol);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.mycompany.mavenproject1;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class MathRounding {
|
||||
public static void main(String[] args) {
|
||||
Scanner scan = new Scanner(System.in);
|
||||
|
||||
double toRound = 1;
|
||||
|
||||
while (toRound != 0)
|
||||
{
|
||||
System.out.println("Time to find out what this shit does: (hit 0 to fuck off) ");
|
||||
toRound = scan.nextDouble();
|
||||
|
||||
if (toRound == 0)
|
||||
break;
|
||||
|
||||
System.out.println("Math.rint gives you " + Math.rint(toRound));
|
||||
System.out.println("Math.ceil gives you " + Math.ceil(toRound));
|
||||
System.out.println("Math.round gives you " + Math.round(toRound));
|
||||
System.out.println("Math.floor gives you " + Math.floor(toRound));
|
||||
}
|
||||
System.out.println("Goodbye!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.mycompany.mavenproject1;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class NegativeChar {
|
||||
public static void main(String[] args) {
|
||||
char lolChar = '\5';
|
||||
System.out.println(lolChar);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.mycompany.mavenproject1;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Q20 {
|
||||
public static void main(String[] args) {
|
||||
int x = 0;
|
||||
int y = 10;
|
||||
while ( -x > -5)
|
||||
{
|
||||
while ( y % 5 == 0 )
|
||||
{
|
||||
|
||||
y -= 5;
|
||||
if ( y < 0 )
|
||||
break;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
System.out.println(x+y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.mycompany.mavenproject1;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Rint {
|
||||
public static void main(String[] args) {
|
||||
System.out.println( Math.rint(5.5) );
|
||||
System.out.println( Math.rint(4.5) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.mycompany.mavenproject1;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class WeirdCharStuff {
|
||||
public static void main(String[] args) {
|
||||
char c = '2' + 2;
|
||||
System.out.println((int) c + 4);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user