DOC PREVIEW
FIU COP 2210 - Laboratory 1: Introduction

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

COP 2210 Laboratory 1: IntroductionCOP 2210 Laboratory 1: IntroductionPartner 1 Name and Section:______________________________________________________Partner 2 Name and Section: ______________________________________________________Objectives:  To learn how to use the NetBeans IDE (Integrated Development Environment) to create,compile, and execute a Java program To compare and contrast the output methods print and println To learn how to use escape sequences To recognize some common compilation errors (i.e., syntax errors), exceptions, and logic errors1: See the document “Using the NetBeans IDE” on the class web site. We are going to create aNetBeans project on our flash drives (or desktop) and then download the Hello.java program,store it in the src folder, compile it, and execute it. We will all do this step together as a classexercise. When you are able to execute the program successfully, call me to check it.Check: ____2: Another class exercise. We will create a new java file called HelloMe.java in the src folder. Itwill be the same as Hello.java but will print “Hello, your name” instead of “Hello, World!”Check: ____3: In HelloMe.java, add a second println statement after the one that prints your name, and have it print “How are you?”Check: ____4: Replace the method name println in the first statement with print. Compile and run the programagain. What is the effect?______________________________________________________________________________5: Change the print back to println and insert the escape sequence \n into the string literal "Hello,World" immediately after the comma. Compile and run the program again. What is the effect?______________________________________________________________________________6: Replace the escape sequence \n with the escape sequence \t. What is the effect?______________________________________________________________________________7: Erase the escape sequence and delete the semi-colon after the first println method call. Inthe second one, delete the closing quotation marks. Compile the program again. Copythe line number and error description for each syntax error reported to the blanks below:____________________________________________________________________________________________________________________________________________________________8: Fix the syntax errors reported in step 7, and compile the program again. Repeat until it compiles with no errors. Now delete the second println statement and change the first one toSystem.Out.println(“Hello, World!”) ;What is the syntax error reported?______________________________________________________________________________9: Fix the syntax error reported in step 8, and compile the program again. Repeat until it compiles with no errors. Now change the println statement tosystem.out.println(“Hello, World!”) ;What is the syntax error reported?______________________________________________________________________________10: Fix the syntax errors reported in step 9, and compile the program again. Repeat until it compileswith no errors. Now change the spelling of main to Main. Compile the program again.Are there any syntax errors reported? _____Run the program. What error message appears? Write it in the space below.______________________________________________________________________________11: Fix the error reported in step 10. Now delete the existing println statements and add this one,exactly as it appears:System.out.println( "The sum of the integers from 1 to 10 is: " + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 ) ;What output did you get?________________________________________________________________________12: In the println statement you added in the previous step, enclose the arithmetic expression 1 + 2+ ... + 9 + 10 in parentheses so that it looks like this:System.out.println( "The sum of the integers from 1 to 10 is: " + (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 ) ) ;Recompile, and run the program again. What output do you get now?________________________________________________________________________Why did you get the correct sum now and not previously in step 11?________________________________________________________________________13: Now replace the arithmetic expression with this one: (1/10 + 2/10 + 3/10 + 4/10 + 5/10 + 6/10 + 7/10 + 8/10 + 9/10 + 10/10) What kind of error results (check one)?Syntax error _____ Exception _____ Logic error _____We will explore this phenomenon in unit 4!In the denominator of each term, replace the literal 10 with 10.0, recompile and run the programagain.Check


View Full Document
Download Laboratory 1: Introduction
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Laboratory 1: Introduction and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Laboratory 1: Introduction 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?