Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CS 1301 – Spring 2016 
Lab 1 
 
Simple Java Programs – Chapter 1 
 
Use JGrasp to write Java programs to print out the following outputs. Referee to Lab Part 1 handout for example 
programs and java syntax (code). 
 
For each lab program you develop during this course, make sure that include the following header - replace the dots 
in the header with your section #, your full name, your instructor’s name, and lab #: 
 
// Class:      CS 1301/... 
// Term:       Spring 2016 
// Name:       ... 
// Instructor: ... 
// Lab:       ... 
 
 
Exercise 1:  Write a Java program (name it Practice_1_1) to print out on separate lines the following: your name, 
your birthday, your hobbies, your favorite book, and your favorite movie. Label each piece of information in the output. 
 
 
Exercise 2:  Write a Java program (name it Practice_1_2) to print out the following shape using stars:  
  
               *  
              * *  
             * * *  
            * * * *  
             * * *  
              * *  
               *  
 
Exercise 3:  Write a java program (name it Practice_1_3) to display the result of  
 
                      1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10  
 
Exercise 4:  Write a java program (name it Practice_1_4) to display the area and perimeter of a rectangle with 
width = 4 and height = 8. Use proper labels for the outputs. 
 
 
Exercise 5:  Assume that a car travels 75 miles in 50 minutes. Write a java program (name it Practice_1_5)  to 
display the average speed in kilometers per hour. Note that 1 mile equals to 1.6 kilometer. 
 
 
Exercise 6:  Study Chapter 1, section 10: Programming Errors, page 20.  
 
1. Type, compile, and run the program in Listing 1.4, page 20. Observe the syntax errors understand them. 
2. Type, compile, and run the program in Listing 1.5, page 21. Observe the run-time error and understand why it 
happened. 
3. Type, compile, and run the program in Listing 1.6, page 22. Observe the output and understand why the code 
gave the wrong output (due to logical error). 
 
 
Submission: 
 
1.  Save all programs. 
2.  Check with your instructor for submission instructions.