jbonanno icon

FortuneTell.Java

jbonanno | PRO | 06/18/17 07:30:46 PM UTC | 0 ⭐ | 278 👁️ | Never ⏰ | []
Java |

6.04 KB

|

None

|

0 👍

/

0 👎

package FortuneTell;
 
 
import java.util.Scanner;
import java.util.ArrayList;
import java.io.*;
 
 
public class FortuneTell {
 
   
    public static void main(String[] args) {
 
 
 
Scanner sc = new Scanner(System.in);
 
 
 
 
    
 
  
 
    public int mainMenu(Scanner sc) {
        String menu = "";
        menu += "FORTUNE TELLER 2000 \n";
        menu += "  Welcome friend!!! This will tell your future! \n";
        menu += "  Please enter the number of your birth month \n";
       menu += "  1: January  \n";
        menu += " 2: February \n";
        menu += " 3: March  \n";
       menu += "  4: April \n";
        menu += " 5: May \n";
          menu += " 6: June \n";
        menu += " 7: July \n";
        menu += " 8: August \n";
       menu += "  9 September \n";
        menu += " 10: October \n";
         menu += " 11: November \n";
          menu += " 12: December \n";
        System.out.println(menu);
            int birthMonth = sc.nextInt();
             System.out.println();
        return birthMonth;
    } 
    
    
    
    
 
private void translateBirthMonth(int birthMonth)
{
if (birthMonth == 1) 
{
  String fortune = "";
        fortune += "You will become very rich \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
else if (birthMonth ==2) 
{
String fortune = "";
        fortune += "You will lose some money \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
else if ( birthMonth == 3 )
{
String fortune = "";
        fortune += "You will meet someone new \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
else if ( birthMonth == 4) 
{
String fortune = "";
        fortune += "You will see another country \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
else if (birthMonth ==5) 
{
String fortune = "";
        fortune += "You will discover the secret of life \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
else if (birthMonth == 6) 
{
String fortune = "";
        fortune += "You will move to a new city \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
 
 if (birthMonth == 7) 
{
String fortune = "";
        fortune += "You may lose touch with a close friend if not careful \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
else if (birthMonth == 8) 
{
String fortune = "";
        fortune += "Your effort will determine your success at your career \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
else if (birthMonth == 9) 
{
String fortune = "";
        fortune += "You will discover a hidden secret \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
 
 
else if (birthMonth == 10) 
{
String fortune = "";
        fortune += "You will solve many problems \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
 
else if (birthMonth == 11) 
{
String fortune = "";
        fortune += "Your dreams will become reality \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
else if (birthMonth == 12) 
{
String fortune = "";
        fortune += "You will climb Mount Everest \n";
        System.out.println(fortune);
        getFavoriteNumbers();
}
// below is validation!
else 
{
 String fortune = "";
        fortune += "ERROR!! Invalid input! Please enter a number between 1 and 12 \n";
        System.out.println(fortune);   
       continue;
 
        }
 
}
 
public int leastFavoriteNumber()
{    
 
try
{
  Scanner in = new Scanner(System.in);
  String number =  "Please enter your first favorite number \n";
System.out.print(number);
int leastFavoriteNum = in.nextInt();
return leastFavoriteNum;
 
}
catch (Exception e)
{
    String error = ""; 
        error += "ERROR!! Invalid input! Please enter an integer \n";
        System.out.println(error); 
        in.next();
       continue;
}
    
}
   
 
 
 
 
public void interpretLeastFavoriteNumber(int leastFavoriteNum)
{
if (leastFavoriteNum < 0)
{
String fortune3 = "";
        fortune3 += "You will climb Mount Everest \n";
        System.out.println(fortune3);
 
}
else if( leastFavoriteNum=< 0 && leastFavoriteNumber >= 10);
{
String fortune3 = "";
        fortune3 += "You are very lucky \n";
        System.out.println(fortune3);
 
else if(leastFavoriteNum > 10)
{
String fortune3 = "";
        fortune3 += "Your special number has special meaning in your life \n";
        System.out.println(fortune3);
 
 
}
 
        
public int getFavoriteNumbers();
{
    int favoriteNumberArray[];
favoriteNumberArray = new int [3];
Scanner in = new Scanner(System.in);
 
  String favorite = "";
        favorite += "Please enter your first favorite numer \n";
favoriteNumberArray[1]  = in.nextInt();
 
String favorite2 = "";
        favorite2 += "Please enter your second favorite numer \n";
favoriteNumberArray[2]  = in.nextInt();
 
String favorite3 = "";
        favorite3 += "Please enter your third favorite numer \n";
favoriteNumberArray[3]  = in.nextInt();
int total = favoriteNumberArray[1]+ favoriteNumberArray[2] + favoriteNumberArray[3];
return total;
}
}
 
public void favoriteNumbersInterpreter(int total)
{
if( total < 0)
{
String fortune2 = "";
        fortune2 += "You will think outside of the box \n";
        System.out.println(fortune2);
}
        else if (total == 0)
        {
            String fortune2 = "";
        fortune2 += "You feel that no one understands you \n";
        System.out.println(fortune2);
        }
        
else if ( total > 0 && total <=10)
{
String fortune2 = "";
        fortune2 += "You like to do things the simple way \n";
        System.out.println(fortune2);
}
else if ( total > 10 && total <=300) 
 
{
String fortune2 = "";
        fortune2 += "You hold many things dear to your heart \n";
        System.out.println(fortune2);
}
else
{
String fortune2 = "";
        fortune2 += "You really think big!! \n";
        System.out.println(fortune2);
}
}

Comments