Write a
*
**
***
**
*
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Software Engineering (10th Edition)
- Write a program that asks the user to enter the coordinates of 4 points that draw two different lines. The program has to display whether these two lines are parallel, perpendicular, or neither according to the following formula: Slope = 22-y1 x2-x1 If the slopes of both lines are equal, the two lines are parallel If the product of both slopes is equal to -1, the 2 lines are perpendicular. Otherwise, the two lines are neither parallel nor perpendicular. Sample Run Enter the 4 coordinates of first line: 5.7 8.9 7 7.8 Enter the 4 coordinates of second line: 5.7 7.6 3.5 8.9 The two lines are neither parallel nor perpendicular BUILD SUCCESSFUL (total tine: 36 seconds)arrow_forwardIn this assignment you will write a program that shows the valid moves of chess pieces. Your program will draw a board with 64 squares using the traditional layout, next ask the user to choose a move, and then, depending on the user's choice, redraw the board with the selected chess piece and its valid moves. Please see the examples of valid moves of chess pieces and the traditional chess board layout below:arrow_forwardWe need to use the java languagearrow_forward
- The Yukon Widget Company manufactures widgets that weigh 9.2 pounds each. Write a program that calculates how many widgets are stacked on a pallet, based on the total weight of the pallet. The program should ask the user how much the pallet weighs by itself and with the widgets stacked on it. It should then calculate and display the number of widgets stacked on the pallet.arrow_forwardUse Python to write a program that asks the user to enter a pocket number and displays whether the pocket is green, red, or black. The program should display an error message if the user enters a number that is outside the range of 0 through 56. On a roulette wheel, the pockets are numbered from 0 to 36. The colors of the pockets are as follows: Pocket 0 is green. For pockets 1 through 20, the odd-numbered pockets are red and the even-numbered pockets are black. For pockets 21 through 38, the odd-numbered pockets are black and the even-numbered pockets are red. For pockets 39 through 48, the odd-numbered pockets are red and the even-numbered pockets are black. For pockets 49 through 56, the odd-numbered pockets are black and the even-numbered pockets are red.arrow_forwardWrite a program that generates a random number in the range of 1 through 1000, and asks the user to guess what the number is. If the user guess is higher than the random number, the program should display Too high, try again. If the users guess is lower than the random number, the program should display Too low, try again. If the user guesses the number, the application should congratulate the user and generate a new random number so the game can start over. If the user doesn't want to continue the game the user should type an appropriate stop symbol to terminate the program (such stop conditions were discussed in the class). For each game iteration, count the number of guesses made by the user and display them. The program should contain the following functions: check_guess(): this function checks if the user's guess is lower, higher or equal to the random number. random_gen(): function that generates one random number for one game iteration main(): the function where the program…arrow_forward
- To make telephine numbers easier to remember, some companies use letters to show their telephone number. For example, the telephine number 438-5626 can be shown as GET-LOAN. In some cases, to make a telephone number meaningful, compaines might use more than seven letters. For example, 225-5466, can be displayed as CALL-HOME, whic uses eight letters. Write a program that prompts the user to enter a telephone number expressesd in letters and outputs the corresponding telephone number in digits. If the user enters more than seven letter, then process only the first seven letters. Also, output the -(hyphen) after the third digit. Allow the user to use uppercase and lowercase letters, as well as spaces between words. Moreover, your program should proces as many telephone as the user wants. (Hint: You can read the entered telephine number as a string and then use the charAt() to extract each character.)arrow_forwardCreate a program where a user guesses whether the value of the sum of two dice will be even or odd. The game will stop when the number of turns has reached 5. To guess odd, the user enters 1. To guess even, the user enters 2. After each roll, the program should display the two numbers rolled,the sum of the numbers, the user's guess as "Even" or "Odd" and whether they won or lost. Once the player ends the game, the program should display the number of times played and the number of turns won and lost and the number of times the dice were even/odd. Technical Requirements: Must use the random function for each die Use a loop to play the game for 5 turns Use an array to track each roll as to whether it was even or oddarrow_forwardpythonarrow_forward
- The text presented the Sierpinski triangle fractal. Inthis exercise, you will write a program to display another fractal, called the Kochsnowflake, named after a famous Swedish mathematician. A Koch snowflake iscreated as follows:1. Begin with an equilateral triangle, which is considered to be the Koch fractalof order (or level) 0, as shown in Figure a.2. Divide each line in the shape into three equal line segments and draw an outwardequilateral triangle with the middle line segment as the base to create aKoch fractal of order 1, as shown in Figure b.3. Repeat Step 2 to create a Koch fractal of order 2, 3, . . . , and so on, as shownin Figures c and d.arrow_forwardPart 1: Complete the survey. Part 2: Peek-a-boo is a fun game that little kids like to play. To simulate this game on the computer, write a program that will generate a random number between 1 and 4. Then, will print to the screen the animal name associated to that number. The animal names used will be: pig when a 1 is generated cow when a 2 is generated chicken when a 3 is generated horse when a 4 is generated If your program generates a 3, the output will be: chicken The player will then enter a 1 if they would like to play again or anything else to exit the program. If the player enters "1 1 1 0", the output will be: horse chicken cow horse For coding simplicity, follow each output animal by a space, even the last one. Hint: To make testing easier, seed your random number generator with 0.arrow_forwardPrimary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90) go east/west. Auxiliary highways are numbered 100-999, and service the primary highway indicated by the rightmost two digits. Thus, the 405 services the 5, and the 290 services the 90. Your program will prompt the user to type a highway number ("Please enter a highway number, Ex: 65: "), read in the number typed by the user, and print out whether it is a primary or auxiliary highway. If auxiliary, indicate what primary highway it serves. Also your program must indicate if the (primary) highway runs north/south or east/west, that it is an invalid number if not between 0 and 999. Ex: If the input is: 90 the output is: The 90 is primary, going east/west. Ex: If the input is: 290 the output is: The 290 is auxiliary, serving the 90, going east/west. Ex: If the input is: 0 the output is: 0 is not a valid interstate highway number. #include <iostream>using…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education