Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Hands On Java Lab 3 Experiment 1 Experiment 1: Simple Expressions   Study the source program Express.java, particularly the lines theScreen.println("\n" + i + '+' + j + " = " + (i + j)); theScreen.println("\n" + x + '+' + y + " = " + (x + y)); In the space below, write what you think will be appear on the screen when this program is executed (don't worry, wrong guesses are not penalized.) Compile Express.java, and run (execute) the resulting program. What is displayed? If what was displayed was what you anticipated, give a detailed explanation of why you said what you did. If what was displayed differs from what you anticipated, explain what was wrong with your thinking. From this, we can see that the effect of the output statement is to display on the screen the value of each Expression in the statement. Simple Expressions An expression that has a single operand and no operators is called a simple expression. Two of the sub-expressions in the output statements in Express.java are not simple expressions. Which of the sub-expressions are not simple expressions? This example illustrates several different kind of simple expressions: '+' is a simple char expression, meaning it produces character values. i and j are simple int expressions, meaning they produce integer (whole number) values. x and y are simple double expressions, meaning they produce real (decimal) values. "\n" and " = " are simple string expressions, meaning they produce a string of characters (return) and (blank, equals, blank) as their respective values.   Output Expressions The final thing to see in this exercise is that the output statement uses a not-so-simple expression. That is, in the lines below theScreen.println("\n" + i + '+' + j + " = " + (i + j)); theScreen.println("\n" + x + '+' + y + " = " + (x + y)); "\n" + i + '+' + j + " = " + (i + j) is a string expression which is evaluated and then printed on your screen. Back to the Exercise List Forward to the Next Experiment Back to the Table of Contents Back to the Introduction Copyright 2000 by Prentice Hall. All rights reserved.