In this lab we will practice with basic types, variables, operators, and keyboard input. Bring your laptop.
We are not using IntelliJ IDEA. We will be using vim (or another text editor) and command line interface with javac and java until further notice.
Download Exercise1.java into a folder on your computer and answer the questions given as comments toward the bottom of the file. When I say "download", I mean download not cut-and-paste. That is, use a right-click and use "Save Link As" or something equivalent on your web browser.
Suggestion: Create a folder named cse114 on your computer and keep everything we do in this course in the folder. You may create a subfolder named lectures and subfolders of it named lec1, lec2, etc. Your folder structure may look something like this:
cse114 assignments assignment1 assignment2 labs lab1 lab2 lab3 lab4 lectures lec1 lec2 lec3
Write a Java class named Division
in a file
named Division.java
capable of dividing and computing the
remainder of two integers.
The program should define two hard-coded (assigned at compile-time) integer variables 'a' and 'b', and should compute the integer part (i.e., quotient) and remainder of a / b.
The program's output should read:
"25 divided by 3 is 8 with a remainder of 1."
Write a Java class named Person
in a file
named Person.java
which asks
for a user's name, age in years, height in feet, and the courses they are
enrolled in this semester. The last prompt just takes the string the user
types and assumes it contains a course list. The program should then display
this information in a readable format. That is, the
output should read something like:
"Amy is 8 years old and 4.2 feet tall." "My courses: I am enrolled in CSE114, MAT125, EST194, and WRT102."
The name should be stored in a String
, the age in
an int
, the height in a double
, and the sentence
in a String
.