Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Can someone walk me through how this program was created?
import java.io.*;
import java.util.*;
public class Prog329f
{
public static void main(String[] args)
{
do
{
System.out.print("Choices of hair style follow:\n1) Parted\n2) Brush Cut\n3) Balding\n4) Mohawk\nEnter Choice: ");
Scanner keyboard = new Scanner(System.in);
int hair = keyboard.nextInt();
System.out.print("\nChoices of eye style follow:\n1) Beady Eyed\n2) Wide Eyed\n3) Wears Glasses\n4) Sleepy Eyes\nEnter Choice: ");
int eyes = keyboard.nextInt();
System.out.print("\nChoices of mouth style follow:\n1) Smiling\n2) Straight Faced\n3) Surprised\n4) Dimples\nEnter Choice: ");
int mouth = keyboard.nextInt();
drawHair(hair);
for (int i = 1; i<=2;i++)
{
faceEdge();
}
drawEyes(eyes);
drawEars();
drawMouth(mouth);
faceEdge();
System.out.println();
}while (nextFace());
}
/* Asks the user if he/she wants to continue
* Pre: User has reached the end of one complete face.
* Post: Method either stops the whole program (if 0 is entered), or loops the questions again in order to make a new face.
*/
public static boolean nextFace()
{
System.out.print("Press any key to continue..[0 to quit] ");
Scanner keyboard = new Scanner(System.in);
String nextFace = keyboard.next();
if (nextFace.equals("0"))
return false;
else
return true;
}
/* Draws the hair of the face/character.
* Pre: User enters hair number choice from 1-4.
* Post: Prints out the hair style chosen by the user.
*/
public static void drawHair(int numEntered)
{
if (numEntered ==1)
System.out.println(" | | | | | / / / / /");
else if (numEntered ==2)
System.out.println(" | | | | | | | | | |");
else if (numEntered ==3)
System.out.println(" |_________________|");
else if (numEntered ==4)
System.out.println(" |______|||||______|");
}
/* Draws the eyes of the face/character.
* Pre: User enters eye number choice from 1-4.
* Post: Prints out the eye style chosen by the user.
*/
public static void drawEyes(int numEntered)
{
if (numEntered ==1)
System.out.println(" | . . |");
else if (numEntered==2)
System.out.println(" | O O |");
else if (numEntered==3)
{
System.out.println(" | ___ ___ |\n |---|_O_|-|_O_|---|");
}
else if (numEntered==4)
System.out.println(" | __ __ |");
}
/* Method draws ears for the character.
* Pre: User has chosen the character's hair and eyes.
* Post: Prints out ears for the character.
*/
public static void drawEars()
{
System.out.println(" _| |_\n|_ _|");
}
/* Draws the mouth of the face/character.
* Pre: User enters mouth number choice from 1-4.
* Post: Prints out the mouth style chosen by the user.
*/
public static void drawMouth(int numEntered)
{
if (numEntered ==1)
System.out.println(" | |_______| |");
else if (numEntered ==2)
System.out.println(" | _______ |");
else if (numEntered ==3)
System.out.println(" | o |");
else if (numEntered==4)
System.out.println(" | )_______( |");
}
/* Prints out edge of head when there is no hair,eyes, or mouth section to draw it.
* Pre: Runs after hair and mouth are drawn.
* Post: Prints out outline for sides/edges of head.
*/
public static void faceEdge()//draw edge of face
{
System.out.print(" |");
for (int n = 1; n<18;n++)
System.out.print(" ");
System.out.print("|\n");
}
}
I know what the program does and I know no one can tell me the programmers exact thought process but If you were teaching someone how to make this program what would you say?
3 Answers
- Anonymous1 decade agoFavorite Answer
There is no way anyone can tell you the exact thought process that went through the programmer's head when he wrote this.
- ruddieLv 44 years ago
properly there are classes which includes Adobe Dreamweaver that are WYSWYG (What you notice is what you get) editors that fantastically plenty walk you for the duration of the technique of arising a internet site. the draw back, although, is that code can each and every each and every now and then get genuine gruesome and not meet standards. additionally, if the positioning desires to be genuine complicated, writing your guy or woman code may be the suitable way.
- Anonymous1 decade ago
Looks like it draws a face based on the input of the user.