Java程序辅导

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

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CS 1301 
Assignment #5 
 
Math Methods, Characters, and Strings – Chapter 4 
 
Use Lab 5 practices for guidance to complete the following programs. 
 
Required:  Use java assert statement to validate program input values. See Chapter 3 slides for code 
examples. Apply this requirement to both lab exercises and assignment programs. 
 
Program #1 (10 points):  Write a Java program (name it StringMethods) that reads from the user two 
strings (say string_1, and string_2). Use String class methods to manipulate these strings as follows. 
Make sure to properly label your output for each manipulation and print the outputs on separate lines. Use the 
tab escape character to line-up the outputs after the labels as follows:  
 
a) proper label . . .:  Output value  
b) proper label . . .:  Output value  
c) proper label . . .:  Output value  
c) proper label . . .:  Output value  
    . . .  
 
a)  Determine the length of string_1. 
b)  Determine the length of string_2. 
c)  Concatenate both strings. 
d)  Check if the two strings have same set of characters with regard to case (i.e., equal). 
e)  Convert string_1 to upper case. 
f)   Convert string_2 to lower case. 
g)  Extract a valid sub-string of multiple characters from string_1. 
  
Separate your code into sections with proper in-line comments such as  
 
// Part A: Determine the length of string_1 
 
Program #2 (10 points):  Write a Java program (name it RandomNumbers) that generates random numbers 
as follows. Make sure to properly label your output for each part below and print the outputs on separate lines. 
As in the previous program, use the tab escape character to line-up the outputs after the labels.  
 
a)  A random integer number between 30 and 50 (inclusive). 
b)  A random integer number between 20 and -20 (inclusive). 
c)  A random integer number between -20 and -60 (inclusive). 
d)  A random floating-point number between 0.0 and 15.9999 (inclusive). 
 
Separate your code into sections with proper in-line comments such as  
 
// Part A: Generate random integer number between 30 and 50 (inclusive) 
 
Program #3 (10 points):  Write a Java program (name it MathMethods) that uses the MATH class methods to 
perform the following tasks. Make sure to properly label your output for each task and print the outputs on 
separate lines. Use the tab escape character to line-up the outputs after the labels.  
 
a) Prompt the user to enter a negative integer number and print out its absolute value.  
b) Prompt the user to enter a floating-point number representing an angle and print out the angle’s 
cosine, sine, and tangent values.  
c) Prompt the user to enter a floating point number and print out both of its floor and ceiling values.  
d) Prompt the user to enter two floating-point numbers (say X and Y) and print out the value of XY (X is 
raised to the power of Y).  
e) Prompt the user to enter an integer number and print out its square root. Try that with both negative 
and positive inputs.  
 
Next Page Î 
 Page 1 of 2
 Page 2 of 2
 
Separate your code into sections with proper in-line comments such as  
 
// Part A: Generate random integer number between 30 and 50 (inclusive) 
 
 
Program #4 (10 points): Work programming exercise 4.13, page 153. Name it VowelConsonant. Run the 
program with different input values. Document the code, properly label the outputs, and organize the outputs 
using escape characters and formatting objects when applicable. 
 
 
Program #5 (10 points): Work programming exercise 4.23, page 156. Name it Payroll. Run the program 
with different input values. Document the code, properly label the outputs, and organize the outputs using 
escape characters and formatting objects when applicable. 
 
 
Submission Instructions: 
 
1. Assignment due date:  Wednesday 2/22/2017  at the beginning of the lab session. 
2. Email your code (only the .java files) to the instructor (hhaddad@kennesaw.edu) and the grader 
(paggarwa@students.kennesaw.edu) before the start of the lab session you attend. Re-submission for any 
reason is considered late submission (see course syllabus - Assignment Grading Policy). 
3. Bring to the lab, on the due date, printed copy of sample outputs (screen-shots) for each program, with 
cover page, stabled together.  Assignment will be collected at the beginning of the lab session. 
1. Before emailing and printing sample outputs, make sure you review the assignment submission 
requirements and grading guidelines posted on the course webpage. The grading guidelines explain some 
of the common errors found in programming assignments. 
2. Follow this example for the subject line of your email submission. For example, Alan Turing in section 01 
would use this subject line in his email:  CS 1301/01, Assignment #05, Alan Turing, Dr. Haddad