Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package week2training;
- public class Day14B {
- public static void main(String[] args) {
- int[] numArray = {10,12};
- int largestNum;
- int smallestNum;
- for (int i : numArray) {
- System.out.println(i);
- }
- largestNum = Math.max(numArray[0], numArray[1]);
- smallestNum = Math.min(numArray[0], numArray[1]);
- System.out.println("Biggest number in array: " + largestNum);
- System.out.println("Smallest number in array: " + smallestNum);
- }
- }
- //---------
- package week2training;
- public class Day14B {
- public static void main(String[] args) {
- int[] numArray = {10,12,15,9,11};
- int largestNum = 0;
- int smallestNum = 0;
- for (int i : numArray) {
- System.out.println(i);
- largestNum = Math.max(largestNum, i);
- smallestNum = Math.min(smallestNum, i);
- System.out.println("Biggest number in array(current): " + largestNum);
- System.out.println("Smallest number in array(current): " + smallestNum);
- }
- }
- }
- //-----------------------------
- System.out.println("Random1: " + Math.round(Math.random() * 10));
- System.out.println("Random2: " + Math.round(Math.random() * 10));
- System.out.println("Random3: " + Math.round(Math.random() * 10));
- System.out.println("Random4: " + Math.round(Math.random() * 10));
- System.out.println("Random5: " + Math.round(Math.random() * 10));
- System.out.println("Random6: " + Math.round(Math.random() * 10));
- //------draw 6 different number(parang lotto)-----------------------
- package week2training;
- public class Day14C {
- public static void main(String[] args) {
- long[] winningNum = {0,0,0,0,0,0};
- int numCount = 0;
- boolean numExist = false;
- long newNumber = 0;
- while (numCount < winningNum.length) {
- newNumber = (Math.round(Math.random() * 41) + 1);
- for (long l : winningNum) {
- if (newNumber == l) {
- numExist = true;
- System.out.println("repeat num: " + newNumber);
- break;
- }
- }
- if (numExist == false) {
- winningNum[numCount] = newNumber;
- System.out.println("new num: " + newNumber);
- numCount++;
- } else {
- numExist = false;
- }
- }
- }
- }
- //-----------------------------
- String txt2 = "The quick brown fox jumps over the lazy dog";
- String txtSearch = "Fox";
- boolean findText = txt2.toLowerCase().contains(txtSearch.toLowerCase());
- System.out.println("do text below contains the word "+ txtSearch + "?");
- System.out.println(txt2);
- System.out.println(".contains() " + findText);
- System.out.println(".endWith() " + txt2.endsWith("Dog"));
- double total = 441.28;
- double paid = 450;
- double change = paid - total;
- System.out.println("The amount due is " + total);
- System.out.println("You paid " + paid + ". Your change is " + change);
- System.out.println("format version:");
- System.out.println(String.format("The amount due is %f", total));
- System.out.println(String.format("You paid %f. Your change is %f", paid , change));
Advertisement
Add Comment
Please, Sign In to add comment