Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I have done this homework all correctly. But when my professor graded it,

ID: 3603807 • Letter: H

Question

Hello, I have done this homework all correctly. But when my professor graded it, I received points off because I never made a PrintFortune method. Can you please do so using my code please. The instructions and my code are presented below.

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 month (a number 1-12) and day of the month (a number 1-13) they were born. Following that the program will display their zodiac sign. Next, the program will ask the user their favorites color (the only choices should be: red, green and blue). Following that the program will display a fortune based on the chosen color. The three fortunes corresponding to the colors are: Red: You will become a gold miner. Green: You will become a forest ranger. Blue: You will sing the blues. Besides the main() method, your program must include a method that returns an integer (1-12) representing the zodiac sign (there are 12 zodiac signs). The method should accept as input parameters two integers (a month and day). The prototype for the method should be: // Returns an integer 1-12 representing the zodiac sign for the given date int GetZodiac (int month, int day); Your program should also contain a method to print the fortune given an integer (1-3) corresponding to the color chosen by the user. The prototype for the method should be: // Prints the fortune (1-3) void PrintFortune (int n); // n=1-3

import java.util.Scanner;

public class FortuneTeller {

//2 ints month and day and returns int for right the zodiac sign

int GetZodiac (int month, int day) {

if((month==3 && day>=21 && day<=31) || (month==4 && day>0 && day<=19))

return 1; //1 for Aries

else if((month==4 && day>=20 && day<=30) || (month==5 && day>0 && day<=20))

return 2; //2 for Taurus

else if((month==5 && day>=21 && day<=31) || (month==6 && day>0 && day<=20))

return 3; //3 for Gemini

else if((month==6 && day>=21 && day<=30) || (month==7 && day>0 && day<=22))

return 4; //4 for Cancer

else if((month==7 && day>=23 && day<=31) || (month==8 && day>0 && day<=22))

return 5; //5 for Leo

else if((month==8 && day>=23 && day<=31) || (month==9 && day>0 && day<=22))

return 6; //6 for Virgo

else if((month==9 && day>=23 && day<=30) || (month==10 && day>0 && day<=22))

return 7; //7 for Libra

else if((month==10 && day>=23 && day<=31) || (month==11 && day>0 && day<=21))

return 8; //8 for Scorpio

else if((month==11 && day>=22 && day<=30) || (month==12 && day>0 && day<=21))

return 9; //9 for Sagittarius

else if((month==12 && day>=22 && day<=31) || (month==1 && day>0 && day<=19))

return 10; //10 for Capricorn

else if((month==1 && day>=20 && day<=31) || (month==2 && day>0 && day<=18))

return 11; //11 for Aquarius

else if((month==2 && day>=19 && day<=29) || (month==3 && day>0 && day<=20))

return 12; //12 for Pisces

else

return -1; //-1 if days do not match with months

}// int Get Zodiac

public static void main(String[] args) { //main method

String name; //name of a person

int month, day, color, zodiac; //bday and color

Scanner reader = new Scanner(System.in);

//fortuneTeller is an instance of FortuneTeller class and this will help in calling GetZodiac function

//main can not call GetZodiac directly as it is a static function

FortuneTeller fortuneTeller = new FortuneTeller();

//user input for name and welcome message

System.out.print("What is your name? ");

name = reader.next();

System.out.println("Welcome "+name+".");

//user input for month and error message if month is incorrect

System.out.print("What month were you born on (1-12)? ");

month = reader.nextInt();

if(month<1 || month>12) {

System.out.println("In our calendar there are only 12 months. Go find your correct birth date and comeback ");

System.exit(0);

}//if statement

//user input for day and get integer of the zodiac sign in variable zodiac

System.out.print("What day of the month were you born on (1-31)? ");

day = reader.nextInt();

zodiac = fortuneTeller.GetZodiac(month,day);

//if zodiac is -1, display the error message

if(zodiac==-1) {

System.out.println("Your birth date does not match the number of days in your birth month. Go find your correct birth date and comeback ");

System.exit(0);

}//if

//other zodiac cases

System.out.print(name+", I see your sign is ");

switch(zodiac) {

case 1:

System.out.println("Aries"); break;

case 2:

System.out.println("Taurus"); break;

case 3:

System.out.println("Gemini"); break;

case 4:

System.out.println("Cancer"); break;

case 5:

System.out.println("Leo"); break;

case 6:

System.out.println("Virgo"); break;

case 7:

System.out.println("Libra"); break;

case 8:

System.out.println("Scorpio"); break;

case 9:

System.out.println("Sagittarius"); break;

case 10:

System.out.println("Capricorn"); break;

case 11:

System.out.println("Aquarius"); break;

case 12:

System.out.println("Pisces"); break;

}//switch

//user input for color

System.out.print("Choose your favorite color (1=red, 2=green, 3=blue): ");

color = reader.nextInt();

switch(color){

case 1:

System.out.println("You will become a gold miner.");

break;

case 2:

System.out.println("You will become a forest ranger.");

break;

case 3:

System.out.println("You will sing the blues.");

break;

default:

System.out.println("You had to enter 1-3 only. Try again from the start");

System.exit(0);

}//switch

}//main method

}//class

Explanation / Answer

FortuneTeller.java

import java.util.Scanner;

public class FortuneTeller {

public static void main(String[] args) {

String name; // name of a person

int month, day, color, zodiac; // bday and color

Scanner reader = new Scanner(System.in);

// user input for name and welcome message

System.out.print("What is your name? ");

name = reader.nextLine();

System.out.println("Welcome " + name + ".");

// user input for month and error message if month is incorrect

while (true) {

System.out.print("What month were you born on (1-12)? ");

month = reader.nextInt();

if (month < 1 || month > 12) {

System.out.println("** Invalid .Must be between 1-12 **");

continue;

} else

break;

}// if statement

// user input for day and get integer of the zodiac sign in variable

// zodiac

while (true) {

System.out.print("What day of the month were you born on (1-31)? ");

day = reader.nextInt();

if (day < 1 || day > 31) {

System.out.println("** Invalid.Must be between 1-31 **");

continue;

} else

break;

}

zodiac = GetZodiac(month, day);

System.out.print(name + ", I see your sign is ");

switch (zodiac) {

case 1:

System.out.println("Aries");

break;

case 2:

System.out.println("Taurus");

break;

case 3:

System.out.println("Gemini");

break;

case 4:

System.out.println("Cancer");

break;

case 5:

System.out.println("Leo");

break;

case 6:

System.out.println("Virgo");

break;

case 7:

System.out.println("Libra");

break;

case 8:

System.out.println("Scorpio");

break;

case 9:

System.out.println("Sagittarius");

break;

case 10:

System.out.println("Capricorn");

break;

case 11:

System.out.println("Aquarius");

break;

case 12:

System.out.println("Pisces");

break;

}// switch

// user input for color

while (true) {

System.out

.print("Choose your favorite color (1=red, 2=green, 3=blue): ");

color = reader.nextInt();

if (color < 1 || color > 3) {

System.out.println("** Invalid.Must be between 1-3 **");

continue;

} else

break;

}

PrintFortune(color);

}// main method

private static void PrintFortune(int color) {

switch (color) {

case 1:

System.out.println("You will become a gold miner.");

break;

case 2:

System.out.println("You will become a forest ranger.");

break;

case 3:

System.out.println("You will sing the blues.");

break;

}

}

private static int GetZodiac(int month, int day) {

int num = 0;

if ((month == 3 && day >= 21 && day <= 31)

|| (month == 4 && day > 0 && day <= 19))

num = 1; // 1 for Aries

else if ((month == 4 && day >= 20 && day <= 30)

|| (month == 5 && day > 0 && day <= 20))

num = 2; // 2 for Taurus

else if ((month == 5 && day >= 21 && day <= 31)

|| (month == 6 && day > 0 && day <= 20))

num = 3; // 3 for Gemini

else if ((month == 6 && day >= 21 && day <= 30)

|| (month == 7 && day > 0 && day <= 22))

num = 4; // 4 for Cancer

else if ((month == 7 && day >= 23 && day <= 31)

|| (month == 8 && day > 0 && day <= 22))

num = 5; // 5 for Leo

else if ((month == 8 && day >= 23 && day <= 31)

|| (month == 9 && day > 0 && day <= 22))

num = 6; // 6 for Virgo

else if ((month == 9 && day >= 23 && day <= 30)

|| (month == 10 && day > 0 && day <= 22))

num = 7; // 7 for Libra

else if ((month == 10 && day >= 23 && day <= 31)

|| (month == 11 && day > 0 && day <= 21))

num = 8; // 8 for Scorpio

else if ((month == 11 && day >= 22 && day <= 30)

|| (month == 12 && day > 0 && day <= 21))

num = 9; // 9 for Sagittarius

else if ((month == 12 && day >= 22 && day <= 31)

|| (month == 1 && day > 0 && day <= 19))

num = 10; // 10 for Capricorn

else if ((month == 1 && day >= 20 && day <= 31)

|| (month == 2 && day > 0 && day <= 18))

num = 11; // 11 for Aquarius

else if ((month == 2 && day >= 19 && day <= 29)

|| (month == 3 && day > 0 && day <= 20))

num = 12; // 12 for Pisces

return num;

}

}// class

__________________

Output:

What is your name? Sachin Tendulkar
Welcome Sachin Tendulkar.
What month were you born on (1-12)? 13
** Invalid .Must be between 1-12 **
What month were you born on (1-12)? 6
What day of the month were you born on (1-31)? 35
** Invalid.Must be between 1-31 **
What day of the month were you born on (1-31)? 28
Sachin Tendulkar, I see your sign is Cancer
Choose your favorite color (1=red, 2=green, 3=blue): 1
You will become a gold miner.

_____________Could you rate me well.Plz .Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote