Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program for a fortune teller. The program should begin by asking the user to enter their name. Following that the program will

Write a Java program for a fortune teller.

The program should begin by asking the user to enter their name. Following that the program will display a greeting.

Next, the program will ask the user to enter the year (a 4-digit number) they were born. Following that the program will display their Chinese Zodiac sign (one of 12 animals). You can find information about the Chinese Zodiac on the Internet and in your textbook.

Next, the program will ask the user their favorites food (the only choices should be: fish, chicken, steak, shrimp). Following that the program will display a fortune based on the chosen food and after that a goodbye message. The three fortunes corresponding to the foods are:

Fish: You will become a computer programmer.

Chicken: You will become a famous musician.

Steak: You will play professional sports.

Shrimp: You will become and astronaut and travel to the moon.

Besides the main() method, your program must include a method that returns an integer (0-11) representing the zodiac sign (there are 12 zodiac signs). The method should accept as input parameters one integer (a year). The prototype for the method should be:

Your program should also contain a method to print the fortune given an integer (1-4) corresponding to the food chosen by the user. The prototype for the method should be:

For example, the output might look like:

What is your name? Steve

Welcome Steve.

What year were you born? 1998

Steve, that was the year of the Rat.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

How would you define the problem in the following case?

Answered: 1 week ago