Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CSE194 assignmnet Programming ASSIGNMENT #2   Assigned: 8/9/06                       Due: 8/18/06 Maximum Points: 20  Topics: Topics from Chapter 2 of the text: Understanding the difference between primitive data and objects. Declaring and using variables. Performing mathematical computations . Using class Scanner to get the input from the user. Part 1: Written Exercises (10 points) Turn in the following questions. Please write only your answers neatly on a sheet of paper with your name printed at the top. You will not receive any partial points for an incorrect answer. 1. Are the following ints and doubles properly declared and/or initialized? If not, supply a correction. (3 pts) double 3.14159; int; double = 314.00 int PI_times = 314.00; int_value 314; double working_value 314; 2. Values on both sides of an assignment (=) operator are checked to insure that the data received matches the data type of the variable to which it will be assigned. Are the right and left hand sides of the assignment operators of compatible type in the following statements? (1.5 pts) int y = 3; double y; int x = x * (6 + y); double y = "3"; 3.What error does your compiler give in these cases? (1/2 pt) Statement Error message a + 2 = 3; 4. What value is assigned to x by each of the following? (4 pts) int x = 6 + 3; int x = 6 * 3; int x = 6 / 3; int x = 7 / 3; double x = 7 / 3; int x = 999 / 1000; double x = 999.0 / 1000.0; int x = 999 / 1000.00; 5. Translate the following algebraic expressions into Java : (1 pt) y = x + 1/2 y = x2 + 2x + 1 Part 2: Programing (10 points) Assignment Documentation: At the beginning of each programming assignment you should have a comment block with the following information: /*------------------------------------------------------------------------- // FILENAME: title of the source file // SPECIFICATION: description of the program // AUTHOR: Your Name // TIME SPENT:: //----------------------------------------------------------------------- Your assignment is to write a complete Java program in a source file to be named Second.java. This file must hold class Second, which has just one method: main. The program prompts the user for an integer value representing a number of seconds, then prints the equivalent amount of time as a combination of hours, minutes, and seconds. (For example, 9999 seconds is equivalent to 2 hours, 46 minutes and 39 seconds). Sample Output: (the user input is shown in bold) *****Second Conversion***** Enter the number of seconds: 87654 Hours: 24 Minutes: 20 Seconds: 54 ********************************************************************************* You are to submit, at the due date, the following items: A printed (hard) copy of the program. A sheet with answers for exercises (just the answers). NO LATE ASSIGNMENTS WILL BE ACCEPTED.