Advertisement
MrDoyle

Untitled

Aug 25th, 2020
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.*;
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         //This program is showing the different variable types
  7.  
  8.         //Printing to screen
  9.         System.out.println("My name is Mr Doyle");
  10.  
  11.         //Printing a number
  12.         System.out.println(56);
  13.  
  14.         //Printing a Boolean
  15.         System.out.println(true);
  16.  
  17.         //Printing a character
  18.         System.out.println('@');
  19.  
  20.         //Assigning a value to a variable
  21.         int myLuckyNumber = 7;
  22.         System.out.println("My lucky number is: " + myLuckyNumber);
  23.  
  24.         //variable review
  25.         int myNumber = 42;
  26.         boolean isFun = true;
  27.         char movieRating = 'A';
  28.  
  29.         //Whitespace       is      not     compiled  by Java
  30.  
  31.         //Single line comment
  32.         /*
  33.  
  34.         Multiline comment
  35.  
  36.          */
  37.  
  38.         //Using operators
  39.         int sum = 34 + 113;
  40.         int difference = 91 - 205;
  41.         int product = 2 * 8;
  42.         int quotient = 45 / 3;
  43.         System.out.println(sum);
  44.         System.out.println("My difference is: " + difference);
  45.         System.out.println("My product is " + product + ", and my quotient is " + quotient);
  46.  
  47.         //Modulo
  48.         int myRemainder = 34 % 8;
  49.         System.out.println("The remainder of 34 / 8 is " + myRemainder);
  50.  
  51.         //Relation operators
  52.         System.out.println("Is 6 < 9?");
  53.         System.out.println(6 < 9);
  54.  
  55.         System.out.println("Is 6 > 9?");
  56.         System.out.println(6 > 9);
  57.  
  58.         //Checking the equality of data (use == to compare values, and use = to set values)
  59.         char myChar = 'A';
  60.         int myInt = -2;
  61.         System.out.println("Checking if A = -2");
  62.         System.out.println(myChar==myInt); //should print false
  63.  
  64.         //summary of concepts so far
  65.         boolean isComplete = true;
  66.         int awesomeLevel = 121;
  67.         int epicLevel = awesomeLevel * 2;
  68.         System.out.println(epicLevel);
  69.  
  70.  
  71.  
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement