## Description

Part A: This question is to be submitted to the instructor in the form a Word document containing the Java code and a screen capture of the output. Upload the file to CMS.

1. [10 marks] A triangle defined as three sides of lengths side1, side2 and side3 is valid only if the sum of any two sides exceeds the remaining third s ide. Write a program that asks the user to enter the lengths of the three sides of a triangle. First, validate that the three sides can define a triangle and if the lengths are invalid report “The lengths do not define a triangle”. If the three sides are valid for a triangle report “The perimeter of the triangle is xxxx.” where xxxx is the sum of side1, side2 and side3.

Enter the three sides of the triangle: 4 5.5 4.5 [Enter] The perimeter of the triangle is 14.0. Enter the three sides of the triangle: 8.2 4.6 3.4[Enter] The lengths do not define a triangle.

Show your program working for the two examples above plus the following additional sets: { 8.6, 12.2, 3.9 } , { 4.1, 7.6, 2.2 }, { 1.4, 2.9, 1.8 }

2. [10 marks] Using the &&, ||and ^ operators, write a program that prompts the user to enter an integer and determines whether it is: a) divisible 7and 13; b) whether it is divisible by 7 or 13; c) whether it is divisible by 7 or 13, but not both. Enter an integer: 91 [ENTER] Is 70 divisible by 7 and 13? true Is 70 divisible by 7 or 13? true Is 70 divisible by 7 or13, but not both? false

Show tests of your program using: 182, 77, 143, and 637. Include one screen shot for each.

3. [15 marks] Problem 4.1, page 150 Demonstrate the program works using r values of: 5.5, 12.6, and 3.1 (Include one screen shot for each).

COSC 1046 (F17) – Introduction to Computer Science Part B: Write code and test the solutions for the following problems from the textbook. Submit the .java files for each question to CMS. The answers are due on October15th and the programs are to be demonstrated to the Teaching Assistant (Tim) by October 20th. He will ask questions to make sure you understand the material. (HINT: If you demonstrate your programs before the due date, Will can give you an opportunity to fix errors and redemonstrate).

1. [15 marks] Problem 3.17, page 111 For this program, I want the game to be “rock, paper, scissors, lizard, Spock”. You will need to generate a random integers from 0 to 4, where 0 is rock, 1 is paper, 2 is scissors, 3 is lizard and 4 is Mr. Spock.

Here are the rules: Scissors cuts paper Paper covers rock Rock smashes lizard Lizard eats paper Paper disproves Spock Spock vaporizes rock Rock smashes scissors Scissors decapitates lizard Lizard poisons spock Spock smashes scissors and as it always has….Rock crushes scissors

Google the game if you are not sure (or watch it on “The Big Bang Theory” tv show).

2. [10 marks] Problem 4.5, page 152

3. [10 marks] Write a program that prompts the user to enter a character and then reports whether it is a number, a letter, or another symbol. If it is a letter, indicate whether it is a vowel or not a vowel.

Enter a character: & [Enter] The character & has the Unicode value of 38 and is a symbol.

Enter a character: a [Enter] The character a has the Unicode value of 97 and is a letter. Also, it is a vowel.

Enter a character: Q [Enter] The character Q has the Unicode value of 81 and is a letter. It is not a vowel.

Enter a character: 4 [Enter] The character 4 has the Unicode value of 52 and is a number.