
Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 4, Problem 16PP
Program Plan Intro
Faces
Program plan:
- Include necessary header files.
- Declare the class “Faces” that extends application class.
- Declare required constant variables.
- Override the “paint ()” method.
- Create a group, scene, canvas and graphics context.
- Declare required variables.
- Loop executes starts from “0” through “5”. If yes,
- Switch to case.
- If the value is “0”,
- Set the color “WHITE” to fill the face.
- Set the angle of the mouth to 180.
- Set the height of the mouth to 15.
- Break the case.
- If the value is “1”,
- Set the color “PINK” to fill the face.
- Set the angle of the mouth to 180.
- Set the height of the mouth to 7.
- Break the case.
- If the value is “2”,
- Set the color “RED” to fill the face.
- Set the angle of the mouth to 0.
- Set the height of the mouth to 7.
- Break the case.
- If the value is “3”,
- Set the color “YELLOW” to fill the face.
- Set the angle of the mouth to 180.
- Set the height of the mouth to 15.
- Break the case.
- If the value is “4”,
- Set the color “GREEN” to fill the face.
- Set the angle of the mouth to 0.
- Set the height of the mouth to 15.
- Break the case.
- To draw a face,
- Draw the face using “drawOval” method.
- Set the stroke color.
- To draw eyes,
- Set the color to fill the eyes.
- Draw the left and right eye using “fillOval” method.
- To draw a nose,
- Set the color to fill it.
- Draw a nose using “fillOval” method.
- To draw a mouth,
- Set the stroke color
- Draw a mouth using “drawArc” method.
- To draw a body,
- Set the stroke color
- Draw a body using “drawOval” method.
- Draw the left and right arms using “drawOval” method.
- Draw the left and right legs using “fillOval” method.
- Switch to case.
Expert Solution & Answer

Want to see the full answer?
Check out a sample textbook solution
Chapter 4 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 4.1 - What output is produced by the following code? int...Ch. 4.1 - Can the body of a while loop execute zero times?...Ch. 4.1 - What output is produced by the following code? int...Ch. 4.1 - Revise the following code so that it uses a while...Ch. 4.1 - What output is produced by the following code? int...Ch. 4.1 - Imagine a program that reads the population of a...Ch. 4.1 - Prob. 7STQCh. 4.1 - What output is produced by the following code? int...Ch. 4.1 - What output is produced by the following code? for...Ch. 4.1 - What output is produced by the following code? for...
Ch. 4.1 - Prob. 11STQCh. 4.1 - Write a for statement that displays the even...Ch. 4.1 - Prob. 13STQCh. 4.2 - Write a Java loop that will display the phrase One...Ch. 4.2 - Write a Java loop that will set the variable...Ch. 4.2 - Write a Java loop that will read a list of numbers...Ch. 4.2 - What output is produced by the following code? for...Ch. 4.2 - What output is produced by the following code? for...Ch. 4.2 - What output is produced by the following code? for...Ch. 4.2 - Revise the loop shown in Listing 4.6 to use a...Ch. 4.2 - What is the bug in the code in the section Tracing...Ch. 4.2 - Add some suitable output statements to the...Ch. 4.2 - What is the bug in the code in the previous...Ch. 4.2 - Prob. 24STQCh. 4.2 - Suppose that you did not have assertion checking...Ch. 4.3 - Prob. 26STQCh. 4 - Write a fragment of code that will read words from...Ch. 4 - Develop an algorithm for computing the...Ch. 4 - Develop an algorithm for a simple game of guessing...Ch. 4 - Write a fragment of code that will compute the sum...Ch. 4 - Convert the following code so that it uses nested...Ch. 4 - Write a for statement to compute the sum 1 + 22 +...Ch. 4 - (Optional) Repeat the previous question, but use...Ch. 4 - Write a loop that will count the number of blank...Ch. 4 - Write a loop that will create a new string that is...Ch. 4 - Write a program that will compute statistics for...Ch. 4 - Suppose we attend a party. To be sociable, we will...Ch. 4 - Define an enumeration for each of the months in...Ch. 4 - Write a fragment of code that computes the final...Ch. 4 - Suppose that you work for a beverage company. The...Ch. 4 - Suppose that we want to compute the geometric mean...Ch. 4 - Prob. 16ECh. 4 - Create an applet that draws a pattern of circles...Ch. 4 - Prob. 18ECh. 4 - What does the following fragment of code display?...Ch. 4 - Repeat Practice Program 4 of Chapter 3, but use a...Ch. 4 - Write a program that implements your algorithm...Ch. 4 - Repeat Practice Program 5 of Chapter 3, but use a...Ch. 4 - Write a program to read a list of nonnegative...Ch. 4 - Write a program to read a list of exam scores...Ch. 4 - Combine the programs from Programming Projects 5...Ch. 4 - Write a program that simulates the Magic 8 Ball...Ch. 4 - Whats for dinner? Let the computer decide. Write a...Ch. 4 - Write a program that implements your algorithm...Ch. 4 - Prob. 2PPCh. 4 - Write a program that reads a bank account balance...Ch. 4 - Modify Programming Project 5 from Chapter 2 to...Ch. 4 - Write a program that asks the user to enter the...Ch. 4 - Write a program that simulates a bouncing ball by...Ch. 4 - You have three identical prizes to give away and a...Ch. 4 - Prob. 9PPCh. 4 - Holy digits Batman! The Riddler is planning his...Ch. 4 - Your country is at war and your enemies are using...Ch. 4 - Prob. 12PPCh. 4 - Prob. 13PPCh. 4 - Prob. 14PPCh. 4 - Prob. 15PPCh. 4 - Prob. 16PP
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY