No Title Essay

7982 Words Aug 24th, 2015 32 Pages
Chapter 2: Data and Expressions
Lab Exercises
Topics

Lab Exercises

Print and println
String literals
String concatenation
Escape sequences

Names and Places
A Table of Student Grades
Two Meanings of Plus

Variables
Constants
Assignment
Integers and Floating point
Arithmetic Expressions
Operator Precedence
Input using the Scanner class

Prelab Exercises
Area and Circumference of a Circle
Painting a Room
Ideal Weight
Lab Grades
Base Conversion

HTML
Applets
Graphics
Colors

Introduction to HTML
Drawing Shapes
The Java Coordinate System
Drawing a Face
Creating a Pie Chart
Colors in Java

Chapter 2: Data and Expressions

8

Names and Places
The goal in this exercise is to develop a program that
…show more content…
Be sure to add a label at the top of the third column and be sure everything is lined up (use tab characters!).

Chapter 2: Data and Expressions

9

A Table of Student Grades
Write a Java program that prints a table with a list of at least 5 students together with their grades earned (lab points, bonus points, and the total) in the format below.
///////////////////\\\\\\\\\\\\\\\\\\\
==
Student Points
==
\\\\\\\\\\\\\\\\\\\///////////////////
Name
---Joe
William
Mary Sue

Lab
--43
50
39

Bonus
----7
8
10

Total
----50
58
49

The requirements for the program are as follows:
1.
2.
3.

Print the border on the top as illustrated (using the slash and backslash characters).
Use tab characters to get your columns aligned and you must use the + operator both for addition and string concatenation. Make up your own student names and points—the ones shown are just for illustration purposes. You need 5 names.

Chapter 2: Data and Expressions

10

Two Meanings of Plus
In Java, the symbol + can be used to add numbers or to concatenate strings. This exercise illustrates both uses.
When using a string literal (a sequence of characters enclosed in double quotation marks) in Java the complete string must fit on one line. The following is NOT legal (it would result in a compile-time error).
System.out.println ("It is NOT okay to go to the next line in a LONG string!!!");
The solution

Related Documents