Hello,
In this post I'm going to submit my Java Fundamentals Homework which is due on 20.10.2015.
I hope, I can help someone with my solutions.
Problem: Assign Variables
Find
suitable types for variables. You are given the following types: byte, short, int, long, char, boolean, float, double, and String. Assign
the following values to them false,
“Palo Alto, CA”, 32767, 2000000000, 0.1234567891011, 0.5f, 919827112351L, 127,
‘c’. Try to assign 32768 to
short and see what happens.
import java.util.Scanner; public class AssignVariables { public static void main(String[] args) { Scanner console = new Scanner(System.in); int integerValue = 2000000000; char characterValue = 'c'; boolean boolValue = false; double doubleValue = 0.1234567891011; String stringVAlue = "Palo Alto, CA"; short shortVAlue = 32767; long longVslue = 919827112351L; float floatValue = 0.5f; byte byteValue = 127; System.out.println(integerValue + ", " + doubleValue); System.out.println(characterValue + ", " + boolValue + ", " + stringVAlue); System.out.println(shortVAlue + ", " + longVslue); System.out.println(byteValue + ", " + floatValue); } }
No comments:
Post a Comment