Class Notes (1,035,963)
CA (593,746)
Dancy (10)
Lecture 3

PROG 10082 Lecture Notes - Lecture 3: FahrenheitPremium

2 pages101 viewsWinter 2016

Computer Engineering Technology
Course Code
PROG 10082

This preview shows half of the first page. to view the full 2 pages of the document.
Java Lecture 3
Classes define what objects look like, they implement things at design time, and objects
are created from classes at run time
visibility defines whether the objects are public or private
primitive type only has lowercase, and they are considered to be keywords
a variable is a class name
Circle biground= new Circle(); this creates and declares the variable
literals are constant values that appear in a program like they can be string or int or
double, it is a constant value
space is also a character
a) -8 b) 2..but isnt this supposed to be (8/9)*(2/1)=-9+16/9. No. It is an integer because it
is truncatied, so it is zero. therefore the right answer is -9
Invalid expressions:
6.0%2 is invalid
6**2 is invalid
1rimw is invalid unless it's a string literal
5/5/5 is valid but the result is zero
%f is float or double, %d or % i is integers
system.out.printf tells you how to format a value in float format
%w.df by default the value shows 6 decimal places
if you want to format the thing as for example 5.3f, then you can allocate the number five
the value here for example is where w is 5, d is 3 for 3 decimal places, and is a float
printf tells us how to format
To Submit in .java files:
area of a sphere having the radius of 1.1
area=(4/3) pi*r^2
print the area to two decimal places
Convert cels to Farenheit, where C is 40
fahrenheit converter
You're Reading a Preview

Unlock to view full version

Subscribers Only

Loved by over 2.2 million students

Over 90% improved by at least one letter grade.