Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class CompSci
- {
- public static void main ( String[] args )
- {
- //define 1 variable of each of the
- //following data types
- //byte short int long
- //float double
- //char boolean String
- Random r = new Random();
- //integer variables
- byte byteOne = 127;
- short shortOne = -32123;
- int intOne = 90877;
- long longOne = 99999999;
- float floatOne = 38.5678f;
- double doubleOne = 923.234;
- char charOne = 65;
- boolean booleanOne = true;
- String stringOne = "hello world";
- double one = 15.0;
- int result = r.nextInt(50);
- result = result + 1;
- int number = r.nextInt(50);
- double two = r.nextInt(50);
- int addition = result + number;
- double plus = one + two;
- char wow = '&';
- System.out.println("/////////////////////////////////");
- System.out.println("*Chris Nick 09/22/16*");
- System.out.println("* *");
- System.out.println("* integer types *");
- System.out.println("* *");
- System.out.println("*8 bit - byteOne = " + byteOne + "\t\t*");
- System.out.println("*16 bit - shortOne = " + shortOne + "\t*" );
- System.out.println("*32 bit - intOne = " + intOne + "\t*");
- System.out.println("*64 bit - longOne = " + longOne + "\t*");
- System.out.println("* *");
- System.out.println("* real types *");
- System.out.println("*32 bit - floatone = " + floatOne + "\t*");
- System.out.println("*64 bit - doubleOne = " + doubleOne + "\t*" );
- System.out.println("* *");
- System.out.println("* other integer types *");
- System.out.println("* *");
- System.out.println("*16 bit - charOne = " + charOne + "\t\t*");
- System.out.println("* *");
- System.out.println("* other types *");
- System.out.println("* *");
- System.out.println("*booleanOne = " + booleanOne + "\t\t*");
- System.out.println("*stringOne = " + stringOne + "\t*");
- System.out.println(one);
- System.out.println(result);
- System.out.println(number);
- System.out.println(two);
- System.out.println(wow);
- System.out.println("The sum of my int's is " + addition);
- System.out.println("The sum of my doubles is " + plus);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement