int passengers; passengers = 0; passengers = passengers + 5; passengers = passengers - 3; passengers = passengers - 1 + 5; System.out.println(passengers); int stops; int fare; stops = 0; fare = 0; stops = stops + 1; fare = fare + 5; stops = stops + 1; fare = fare + 3; stops = stops + 1; fare = fare + 7; Systeml.out.println(stops);
String driver; driver = "Hamish"; int letters = driver.length(); System.out.println(letters); driver = driver.toUpperCase(); System.out.println(driver);
String driverFirstName; driverFirstName = "Hamish"; String driverLastName; driverLastName = "Blake"; String driverFullName = driverFirstName + " " + driverLastName; System.out.println(driverFullName); System.out.println("The bus made $"+fare+" after "+stops+"stops");
data type
int maxInt = 2147483647; long muchMore = 2147483647*10000000; double fraction = 99.275; String fullText = "(b) WWII ended 1945"; char answer = 'b'; char three = '3'; boolean fact = true;
double current = 17; double rate = 1.5; double future = current * rate; System.out.println(future); int approx = (int) future; System.out.println(approx);
casting
int x = 5; int y = 2; double div = x/y; System.out.println(div); double accurate = (double)x/y; System.out.println(accurate);
average
double maths=97.5; double english=98; double science=83.5; double drama=75; double music=96; double sum=maths+english+science+drama+music; double average=sum/5; System.out.println(average);