You are on page 1of 11

import java.util.

ArrayList;
import java.util.Scanner;

public class Myprojectv20 {


static Scanner am = new Scanner(System.in);

public static void main(String[] args) {

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
System.out.print(" HELLO, HOW ARE YOU? I AM JO-ANNE MEJOC AND I AM GOING
TO SHOW YOU MY OOP MIDTERM PROJECT\n");
System.out.print(" KINDLY CHOOSE A PROGRAM\n");
mainn();
} public static void mainn() {

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
System.out.print("HAVE A NICE DAY\n");
System.out.print("[1] INPUT USER INFORMATION\n");
System.out.print("[2] FOUR MATH OPERATIONS\n");
System.out.print("[3] VOLUME OF CONE & SPHER AND AREA OF TRIANGLE AND
RECTANGLE\n");
System.out.print("[4] IF-ELSE PROGRAM\n");
System.out.print("[5] ARRAY EXAMPLES\n");
System.out.print("[6] Recursion\n");
System.out.print("[7] Inheritance\n");
System.out.print("[8] PRESS 8 TO END THE PROGRAM\n");
System.out.println("|PRESS THE NUMBER OF YOUR CHOSEN PROGRAM|");
System.out.print(": ");
int chosen = am.nextInt();

switch(chosen) {
case 1:
Scanner JMejoc = new Scanner (System.in);
System.out.print(" PLEASE CHOOSE A PROGRAM\n");
System.out.print("[1] USER NAME, AGE AND BIRTHDAY\n");
System.out.print("[2] BMI OF USER\n");
System.out.println("[3] SIMPLE INTEREST");
System.out.println("[4] Return");

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~");
System.out.print(": ");

int choice = JMejoc.nextInt();


switch (choice){
case 1:
Scanner name = new Scanner(System.in);
String Lname, Mname, Fname, Bmonth;
int Bday, Byear;
int Cyear = 2022;

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~");
System.out.print("ENTER YOUR FIRST NAME: ");Fname = name.nextLine();
System.out.print("ENTER YOUR MIDDLE NAME: ");Mname = name.nextLine();
System.out.print("ENTER YOUR LAST NAME: ");Lname = name.nextLine();
System.out.print("ENTER YOUR BIRTH MONTH: ");Bmonth = name.nextLine();
System.out.print("ENTER YOUR BIRTH DAY: ");Bday = name.nextInt();
System.out.print("ENTER YOUR BIRTH YEAR: ");Byear = name.nextInt();

System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~\n");
System.out.print("\nHI! "+Fname+" "+Mname.charAt(0)+" "+Lname+"!!");
int age = Cyear - Byear;
System.out.println(age+" YEARS OLD");
System.out.println("BORN ON "+Bmonth+" "+Bday+", "+Byear+"");
System.out.println("WELCOME TO MY PROGRAM!!");
returnss();
break;

case 2:
System.out.print("INPUT WEIGHT IN KILOGRAM: ");
double weight = am.nextDouble();
System.out.print("INPUT HEIGHT IN METERS: ");
double height = am.nextDouble();
double BMI = weight / (height * height);
System.out.print("THE BODY INDEX (BMI) OF THE USER IS " + BMI + "
kg/m2\n");
returnss();

break;

case 3:
int PA;
double R, T, SI;
Scanner BUT = new Scanner(System.in);
System.out.print("ENTER PRINCIPAL AMOUNT: ");PA =
BUT.nextInt();
System.out.print("ENTER RATE: ");R =BUT.nextInt();
System.out.print("ENTER TIME: ");T = BUT.nextInt();
SI = (PA*R*T)/100;
System.out.print("THE SIMPLE INTEREST IS "+SI);

returnss();

case 4: mainn();
break;
}
break;
case 2:
try (Scanner JAM1 = new Scanner(System.in)) {

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
System.out.print("1. ADDITION\n");
System.out.print("2. SUBTRATION\n");
System.out.print("3. MULTIPLICATION\n");
System.out.print("4. DIVITION\n");
System.out.print("KINDLY USE THE MATHEMATICAL
EQUATION YOU PREFER TO RUN: ");
try {
int schosen = JAM1.nextInt();
switch (schosen){
case 1:

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
System.out.print(" YOU'VE CHOSEN ADDITION\
n");
System.out.print(" ENTER YOUR FIRST NUMBER: ");
int num1 = JAM1.nextInt();
System.out.print(" ENTER YOUR SECOND NUMBER: ");
int num2 = JAM1.nextInt();
int sum = num1+num2;
System.out.println(" THE SUM IS:" +sum);
returnss();
break;
case 2:

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
System.out.print(" YOU'VE CHOSEN
SUBTRACTION\n");
System.out.print(" ENTER YOUR FIRST NUMBER: ");
int numb1 = JAM1.nextInt();
System.out.print(" ENTER YOUR SECOND NUMBER: ");
int numb2 =JAM1.nextInt();
int diff = numb1-numb2;
System.out.println(" THE DIFFERENCE IS:" +diff);
returnss();
break;
case 3:

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
System.out.print(" >>YOU'VE CHOSEN
MULTIPLICATION<<\n");
System.out.print(" >>ENTER YOUR FIRST NUMBER: ");
int numbe1 = JAM1.nextInt();
System.out.print(" >>ENTER YOUR SECOND NUMBER:
");
int numbe2 = JAM1.nextInt();
int prod = numbe1*numbe2;
System.out.println(" >>THE PRODUCT IS:" +prod);
returnss();
break;
case 4:

System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
System.out.print(" >>YOU'VE CHOSEN
DIVISION<<\n");
System.out.print(" >>ENTER YOUR FIRST NUMBER: ");
int number1 = JAM1.nextInt();
System.out.print(" >>ENTER YOUR SECOND NUMBER:
");
int number2 = JAM1.nextInt();
int qout = number1/number2;
System.out.println(" >>THE QOUTIENT IS:" +qout);
returnss();
break;
default:
System.out.println("You Entered An Invalid Choice \nA Valid
Choice Is Only 1, 2, 3, And 4");
}}
catch (Exception b) {
System.out.println("INVALID INPUT");
returnss();
}
}

break;

case 3:
try (Scanner jm = new Scanner(System.in)) {

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
System.out.print("1. VOLUME OF CONE\n");
System.out.print("2. VOLUME OF SPHERE\n");
System.out.print("3. AREA OF RECTANGLE\n");
System.out.print("4. AREA OF TRIAGLE");
System.out.println("PLEASE CHOOSE WHAT TO
COMPUTE");
System.out.print(": ");

try {
int choice3 = jm.nextInt();
switch (choice3){
case 1:
double jmpi=4.14;

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
System.out.print(" >>>VOLUME OF CONE<<<\n");
System.out.print("Enter The Radius Of A Cone: ");
double jmradius=jm.nextFloat();
System.out.print("Enter The Height Of A Cone: ");
double jmheight=jm.nextFloat();
double
jmvolume=(2/4.0)*jmpi*jmradius*jmradius*jmheight;
System.out.println("Volume Of The Cone Is:"+jmvolume);
returnss();
break;
case 2:

System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
System.out.print(" >>>VOLUME OF SPHERE<<<\n");
System.out.print("Enter The Radius Of Sphere: ");
double jmr=jm.nextDouble();
double jmvolume1= (5*26*jmr*jmr*jmr)/(6*2);
System.out.println("Volume Of Sphere is:"+jmvolume1);
returnss();
break;
case 3:

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
System.out.print(" >>>AREA OF RECTANGLE<<<\n");
System.out.print("Enter The Length Of Rectangle: ");
double jmlength = jm.nextDouble();
System.out.print("Enter The Width Of Rectangle: ");
double jmwidth = jm.nextDouble();
double jmarea = jmlength*jmwidth;
System.out.println("Area Of A Rectangle Is: "+
jmarea);
returnss();
break;
case 4:

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
System.out.print(" >>>AREA OF TRIANGLE<<<\n");
System.out.print("Enter The Width Of The Triangle: ");
double jmb= jm.nextDouble();
System.out.print("Enter The Height Of The Triangle: ");
double jmh= jm.nextDouble();
double jmarea1=(jmb*jmh)/2;
System.out.println("Area Of Triangle Is: " + jmarea1);
returnss();
break;
default:
System.out.println("You Entered An Invalid Choice \nA
Valid Choice Is Only 1, 2, 3, And 4");
returnss();

}}
catch (Exception b) {
System.out.println("INVALID INPUT");
}
}
break;

case 4:

int qual = 18;


double fail = 3.1;

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~\n");
Scanner jm = new Scanner(System.in);
System.out.print(" 1. KNOWING IF YOU GRADE IS PASS OR
FAIL\n");
System.out.print(" 2. KNOWING IF YOU ARE QUALIFIED TO
VOTE\n");
System.out.print(" 3. KNOWING IF YOU CAN BE ARRESTED\n");
System.out.println(" 4. KNOWING IF YOUR HEIGHT IS
QUALIFIED FOR ARMY");
System.out.print(": ");
int pinili = jm.nextInt();
switch (pinili){
case 1:

System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
System.out.print("WHAT'S YOUR AVERAGE (COLLEGE GRADING
SYSTEM): ");
double avg = jm.nextDouble();
if (avg<=fail){
System.out.println("CONGRATULATION YOU PASSED!!
^_^");
returnss();}
else {
System.out.println("SORRY YOU FAILED, STUDY WELL -
_-");
returnss();
}break;
case 2:

System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
System.out.print("INPUT YOUR AGE: ");
int age1 = jm.nextInt();
if (age1>=qual){
System.out.println("ACCESS GRANTED YOU CAN VOTE
^_^");returnss();}
else{
System.out.println("SORRY YOU'RE UNDERAGE YOU CAN'T
VOTE RIGHT NOW ^_^");
returnss();}break;
case 3:

System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
System.out.print("INPUT YOUR AGE: ");
int age2 = jm.nextInt();
if (age2>=qual){
System.out.println("YAY!! YOU'RE OLD ENOUGH, BE
CAREFUL!! ^_^");
returnss();}
else {
System.out.println("NOPE YOU CAN'T BE ARRESTED YOU'RE
STILL A MINOR ^_^");
returnss();}break;
case 4:
double qual1 = 152.4;
double qual2 = 147.32;

System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
System.out.println("KINDLY PRESS NUMBER 1 IF YOU ARE A MAN
AND KINDLY PRESS 2 IF YOU ARE A LADY");
int gender = jm.nextInt();
switch (gender){
case 1:
Scanner a = new Scanner(System.in);
System.out.print("ENTER YOUR HEIGHT: ");
int h = a.nextInt();
if (h>qual1){
System.out.println("CONGRATS YOU'RE QUALIFIED TO
JOIN THE ARMY ^_^");
returnss();}
else {
System.out.println("SORRY BUT YOU DON'T MEET THE
REQUIREMENTS ^_^");}
returnss(); break;
case 2:
Scanner b = new Scanner(System.in);
System.out.print("ENTER YOUR HEIGHT: ");
int h1 = b.nextInt();
if (h1>qual2){
System.out.println("CONGRATS YOU'RE QUALIFIED TO
JOIN THE ARMY ^_^");
returnss();}
else {
System.out.println("SORRY BUT YOU DON'T MEET THE
REQUIREMENTS ^_^");
returnss();}
break;
}}
break;

case 5:

System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
Scanner kulot = new Scanner(System.in);
System.out.print(" 1. FIRST EXAMPLE\n");
System.out.print(" 2. SECOND EXAMPLE\n");
System.out.print(" 3. THIRD EXAMPLE\n");
System.out.print(" 4. FOURTH EXAMPLE\n");
int napili = kulot.nextInt();
switch (napili){
case 1:
System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
int[] lotlot = {12, 4, 5, 2, 5};
System.out.println("FIRST EXAMPLE:");
System.out.println("FIRST ELEMENT OF AN ARRAY: " + lotlot[0]);
System.out.println("SECOND ELEMENT OF AN ARRAY: " + lotlot[1]);
System.out.println("THIRD ELEMENT OF AN ARRAY: " + lotlot[2]);
System.out.println("FOURTH ELEMENT OF AN ARRAY: " + lotlot[3]);
System.out.println("FIFTH ELEMENT OF AN ARRAY: " + lotlot[4]);
returnss();
break;
case 2:
System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
int[] age = {15, 3, 6};
System.out.println("ARRAY FOR LOOP:");
for(int i = 0; i < 3; i++) {
System.out.println(age[i]);}
returnss();
break;
case 3:
System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
ArrayList<String> bt3 = new ArrayList<>();
bt3.add("Jo-anne");
bt3.add("Adlawan");
bt3.add("Mejoc");
System.out.println("ArrayList: " + bt3);
returnss();
break;
case 4:
System.out.print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~\n");
ArrayList<Integer> but = new ArrayList<>();
but.add(2);
but.add(3);
but.add(5);
but.add(7);
System.out.println("ArrayList: " + but);
int size = but.size();
System.out.println("Length of ArrayList: " + size);
returnss();
break;}
break;
case 6: recursion();
break;

case 7:

public static void returnss() {


System.out.print("\nDo you want to go back to Main menu [Y] yes [N] no : ");
try (Scanner JAM12 = new Scanner(System.in)) {
char recursions=JAM12.next().charAt(0);
if(recursions == 'Y' || recursions == 'y')
{ mainn();}
else{ System.out.println("HAVE A WONDERFUL DAY, THANK YOU FOR RUNNING
MY PROGRAM! MAY YOU HAVE A BLAST");

System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~");
}
}
} public static void recursion() {
try (Scanner JAM12 = new Scanner(System.in)) {
System.out.println("\n[Recursion]");
System.out.println("Difinition: Recursion is the technique of making a
function call itself. \nThis technique provides a way to break complicated problems
down into simple problems \nwhich are easier to solve.");
System.out.print("\nEnter Y to continue : ");
char recursions=JAM12.next().charAt(0);
if (recursions == 'y' || recursions == 'Y') {
System.out.println("Source code");
System.out.println("\npublic static void recursion() {\r\n"
+ " try (Scanner JAM12 = new Scanner(System.in)) {\r\n"
+ " System.out.println(\"\\n[Recursion]\");\r\n"
+ " System.out.println(\"Difinition: Recursion is
the technique of making a function call itself. This technique provides a way to
break complicated problems down into simple problems which are easier to
solve.\");\r\n"
+ " System.out.println(\"\\nEnter Y to
continue : \");\r\n"
+ " char recursions=JAM12.next().charAt(0);\r\n"
+ " if (recursions == 'y' || recursions == 'Y') {\
r\n"
+ " //code programs\r\n"
+ " \r\n"
+ " System.out.print(\"Enter |run| to run the code
: \");\r\n"
+ " String runrecursion = JAM12.nextLine();\r\n"
+ " if(runrecursion == \"run\" || runrecursion ==
\"Run\" || runrecursion == \"RUN\") { \r\n"
+ " recursioncal();\r\n"
+ " }\r\n"
+ " } else {\r\n"
+ " System.out.println(\"\\nYou Enter an Invalid
Input please try agaain\"); recursion();\r\n"
+ " } \r\n"
+ " } \r\n"
+ " } public static void recursioncal() {\r\n"
+ " float Sumof;\r\n"
+ " try (Scanner JAM12 = new Scanner(System.in)) {\r\n"
+ " System.out.println(\"\\nSimple Recursion
calculator\");\r\n"
+ " System.out.print(\"Enter your first number :
\");\r\n"
+ " int fnum = JAM12.nextInt();\r\n"
+ " System.out.print(\"Enter your second number :
\");\r\n"
+ " int snum = JAM12.nextInt();\r\n"
+ " System.out.println(\"Choose your
operator(*,/,+,-)\");\r\n"
+ " char op=JAM12.next().charAt(0);\r\n"
+ " switch(op) { \r\n"
+ " case '*': Sumof = fnum * snum;\r\n"
+ " System.out.println(\"\"+fnum+\" multiplied
by \"+snum+\" = \"+Sumof);\r\n"
+ " goback();\r\n"
+ " break;\r\n"
+ " case '/': Sumof = fnum / snum;\r\n"
+ " System.out.println(\"\"+fnum+\" Divided by
\"+snum+\" = \"+Sumof);\r\n"
+ " goback();\r\n"
+ " break; \r\n"
+ " case '+': Sumof = fnum + snum;\r\n"
+ " System.out.println(\"\"+fnum+\" Added
by \"+snum+\" = \"+Sumof);\r\n"
+ " goback();\r\n"
+ " break;\r\n"
+ " case '-': Sumof = fnum - snum;\r\n"
+ " System.out.println(\"The diff.
between \"+fnum+\" and \"+snum+\" = \"+Sumof);\r\n"
+ " goback();\r\n"
+ " break;\r\n"
+ " default: System.out.println(\"\\nYou Enter
an Invalid Input please try agaain\"); recursion();\r\n"
+ " break;\r\n"
+ " }\r\n"
+ " }\r\n"
+ " } public static void goback() {\r\n"
+ " System.out.print(\"\\nDo you want to go back to
Main menu [Y] yes [N] no : \");\r\n"
+ " try (Scanner JAM12 = new Scanner(System.in)) {\r\n"
+ " char recursions=JAM12.next().charAt(0);\r\n"
+ " if(recursions == 'Y' || recursions == 'y') {\r\
n"
+ " main(args); } else
{ System.out.println(\" HAVE A WONDERFUL DAY, THANK YOU FOR RUNNING MY PROGRAM!
MAY YOU HAVE A BLAST\");\r\n"
+ "

System.out.print(\"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~\\n\");\r\n"
+ " System.exit(0);}\r\n"
+ " }\r\n"
+ " }");
System.out.print("Enter |R| to run the code : ");
char runrecursion=JAM12.next().charAt(0);
if(runrecursion == 'R') {
recursioncal();
} else {recursion();}
}
}
} public static void recursioncal() {
float Sumof;
try (Scanner JAM12 = new Scanner(System.in)) {
System.out.println("\nSimple Recursion calculator");
System.out.print("Enter your first number : ");
int fnum = JAM12.nextInt();
System.out.print("Enter your second number : ");
int snum = JAM12.nextInt();
System.out.println("Choose your operator(*,/,+,-)");
char op=JAM12.next().charAt(0);
switch(op) {
case '*': Sumof = fnum * snum;
System.out.println(""+fnum+" multiplied by "+snum+" = "+Sumof);
returnss();
break;
case '/': Sumof = fnum / snum;
System.out.println(""+fnum+" Divided by "+snum+" = "+Sumof);
returnss();
break;
case '+': Sumof = fnum + snum;
System.out.println(""+fnum+" Added by "+snum+" = "+Sumof);
returnss();
break;
case '-': Sumof = fnum - snum;
System.out.println("The diff. between "+fnum+" and "+snum+" =
"+Sumof);
returnss();
break;
default: System.out.println("\nYou Enter an Invalid Input please
try agaain"); recursion();
break;
}
}//inheritance
}

//Roses are Red


//Violets are blue
//i can spend 12 years of my life
//just to stare the donut of you

You might also like