In Exercises 39 through 44, write a
Simulate a traffic light with three small square text boxes placed vertically on a form. See
Fig. 2.29. Initially, the bottom text box is solid green and the other text boxes are dark gray.
When the Tab key is pressed, the middle text box turns yellow and the bottom text box turns
dark gray. The next time Tab is pressed, the top text box turns red and the middle text box
turns dark gray. Subsequent pressing of the Tab key cycles through the three colors. Hint: First place the bottom text box on the form, then the middle text box, and finally the top text box.
Learn your wayIncludes step-by-step video
Chapter 2 Solutions
Pearson eText for Introduction to Programming Using Visual Basic -- Instant Access (Pearson+)
Additional Engineering Textbook Solutions
Digital Fundamentals (11th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Artificial Intelligence: A Modern Approach
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Software Engineering (10th Edition)
- TASK 3 In number theory, a happy number is a number which eventually reaches 1 when replaced by the sum of the square of each digit. For instance, 13 is a happy number because 12 + 3? = 10 and 12 + 0² = 1. On the other hand, 4 is not a happy number because the sequence starting with 4? = 16 and 12 + 6? = 37 and eventually reaches to 4 that is the number that started the sequence, and so the process continues in an infinite cycle without ever reaching 1. Write, Compile and Execute a Java method that computes whether a given number is happy or sad.arrow_forwardExercise 4 Write a program that allows a user to play HiLo game. User wins if he/she can guess the number between 1 and 100 within at most 6 iterations. • If s/he guesses a number greater than the secret number. The message shown is "It is Higher than secret shown" • If s/he guesses a number lower than the secret number. The message shown is “ It is Lower than secret" • If the guessed number equal to the secret number. The message shown is "Cong! you won" • If the user consumed the 6 trails without finding the secret number a message "Sorry! Try again" will be shown before termination. Output - CppApplication_1 (Run) #3 Enter a positive integer seed value: 100 Enter your guess : 40 It is Higher than secret Enter your guess : 20 It is Higher than secret Enter your guess : 10 It is Lower than secret Enter your guess : 15 It is Lower than secret Enter your guess : 17 It is Lower than secret Enter your guess : 18 Cong! you won PE Outputarrow_forwardModify the BarChart program from Chapter 6 Exercise 13 to accept the number of points scored by each player in a season. The bar chart displays one asterisk for each 10 points scored by a player. For example, if a player has scored 48 points, then display 4 asterisks. An example of the program is shown below: Enter points earned for the season by Art >> 10 by Bob >> 20 by Cal >> 30 by Dan >> 40 by Eli >> 50 Points for Season (each asterisk represents 10 points) Art * Bob ** Cal *** Dan **** Eli ***** import java.util.Scanner; public class BarChart2 { public static void main (String[] args) { Scanner input = new Scanner(System.in); int artPoints; int bobPoints; int calPoints; int danPoints; int eliPoints; final int AMT_EACH_ASTERISK = 10; System.out.println("Enter points earned for the season"); System.out.print(" by Art >> "); artPoints = input.nextInt();…arrow_forward
- Locate a Letter Write a program that requests a letter, converts it to uppercase, and gives its first position in the sentence “THE QUICK BROWN FOX JUMPS OVER A LAZY DOG.” See Fig. 3.31.arrow_forwardWrite a program that rotates a Ellipse when the Rotate button is clicked, as shown in Figure 15.26b.arrow_forward8. A game is played by moving a game piece left or right along a horizontal game board. The board consists of spaces of various colors, as shown. The circle represents the initial location of the game piece. Yellow Black Green Green Red Yellow Black Black Yellow Black The following algorithm indicates how the game is played. The game continues until the game is either won by landing on the red space or lost when the piece moves off either end of the board. Step 1: Place a game piece on a space that is not red and set a counter to 0. Step 2: If the game piece is on a yellow space, move the game piece 3 positions to the left and go to step 3. Otherwise, if the game piece is on a black space, move the game piece 1 position to the left and go to step 3. Otherwise, if the game piece is on a green space, move the game piece 2 positions to the right and go to step 3. Step 3: Increase the value of the counter by 1. Step 4: If game piece is on the red space or moved off the end of the game…arrow_forward
- Write pseudocode for each example (a through e) in Exercise 2, making sure your pseudocode is structured and accomplishes the same tasks as the flowchart segment.arrow_forwardThe Fibonacci series is a series that begins with 0 and 1 and has the property that each succeeding term is the sum of the two preceding terms. For example, the third Fibonacci number is 1 which is sum of 0 and 1. The next is 2, which is a sum of 1 + 1. Write a program that displays the first ten numbers in a Fibonacci series.arrow_forwardMoney Counting Algorithm: Write a program that shows how much the 25 cents, 50 cents and 1 TL coins you put on paper are worth using the size and color information. The algorithm is entirely up to you. Explain the algorithm you developed, add code and images. b) Heads and Tails Detection Algorithm: Write the program that shows whether the coin placed on the paper is heads or tails. Developing the algorithm is entirely up to you. This algorithm should work in three currencies. (If you find a suitable code, etc. somewhere, it is a direct copy. Your codes should be in accordance with the lectures. Put explanations about what you are doing).arrow_forward
- Skydiving Bibi is a skydiving instructor. Before carrying out skydiving activities, Bibi will always ask the name, height, and age of the participants. Bibi's participants is always 2 people. To make it easier to remember their identities, Bibi gave them a paper to write down their identity. But because they are very enthusiastic in doing skydiving, they write their identity in a single line only (for both of the participants), so it wasn't quite neat and it made difficult for Bibi to see it, and resulted in the skydiving process being disturbed. As one of the organizer committee, you do not want this activity to be disturbed and plan to provide a program that provides their identity neatly to Bibi. Format Input Input consists of 1 line. It contains the identity of 2 people in a row Ni, Ti, Ui - the name, height, and age of the i-th participant. Format Output The output consists of 6 lines. The first line, "Name 1: N1". The second line, "Height 1: T1". The third line, "Age: U1". For…arrow_forwarduse numbers in second picture rather than first pleasearrow_forwardAsaparrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning