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

Valentine.java Create a Valentine.java program that will receive two FBS as desc

ID: 3623433 • Letter: V

Question

Valentine.java Create a Valentine.java program that will receive two FBS as described above and determine their match rating. The basis in determining whether they match should be based on the following criteria:

(a) Sex - they should match; i.e., M-F and F-M match but M-M and F-F do not; if they match, then rating should be 100% otherwise, it should be 0%.

(b) Age - the ages should match; the closer the age gap, the better the match rating; e.g. if age gap is more than 4 years then 25%; 3 years is 50%, 2 years is 75%; 1 year is 90%; and same age is 100%.

(c) Their names should match ... invent some kind of algorithm to determine this..you could use Math.random() or something.

The final match rating is the product of these three ratings.

Sample run:

> java Valentine

Person 1:
Please enter name: Juan Paolo N. Dela Cruz
Please enter your birth date (dd-mm-yyyy) : 23-02-1978
Please enter sex (M/F) : M
Person 2:
Please enter name: Maria Theresa D. Santos
Please enter your birth date (dd-mm-yyyy) : 04-06-1979
Please enter sex (M/F) : F

Match Rating:
Sex: 100%
Age: 90%
Name: 96%

Final: 86%

 

P.S. I need a code that uses import java.io.*

Explanation / Answer

please rate - thanks

import java.io.*;
public class Valentine
{
public static void main(String[] args)throws IOException
{BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
char sex1,sex2;
String name1,name2,dob;
int age1,age2,s,a,m,n;

String sday,smonth,syear;
int eday,emonth,eyear;
System.out.println("Person 1: ");
System.out.print("Please enter name: ");
name1=in.readLine();
System.out.print("Please enter your birth date (dd-mm-yyyy) :");
dob=in.readLine();
smonth=dob.substring(0,2);
sday=dob.substring(3,5);
syear=dob.substring(6,10);
emonth=Integer.parseInt(smonth);
eday=Integer.parseInt(sday);
eyear=Integer.parseInt(syear);
BirthDate date=new BirthDate(emonth,eday,eyear);
age1=date.getAge();
System.out.print("Please enter sex (M/F) : ");
sex1=in.readLine().charAt(0);
System.out.println("Person 2: ");
System.out.print("Please enter name: ");
name2=in.readLine();
System.out.print("Please enter your birth date (dd-mm-yyyy) :");
dob=in.readLine();
sday=dob.substring(0,2);
smonth=dob.substring(3,5);
syear=dob.substring(6,10);
emonth=Integer.parseInt(smonth);
eday=Integer.parseInt(sday);
eyear=Integer.parseInt(syear);
BirthDate date2=new BirthDate(emonth,eday,eyear);
age2=date2.getAge();
System.out.print("Please enter sex (M/F) : ");
sex2=in.readLine().charAt(0);
if(sex1==sex2)
     s=0;
else
     s=100;
System.out.println("Sex: "+s+"%");
System.out.println(Math.abs(age1-age2));
if(Math.abs(age1-age2)>4)
     a=25;
else if(Math.abs(age1-age2)>3)
      a=50;
else if(Math.abs(age1-age2)>2)
     a=75;
else if(Math.abs(age1-age2)>1)
     a=90;
else
     a=100;
System.out.println("Age: "+a+"%");
m=name1.length();
if(name2.length()>m)
     m=name2.length();
n=(int)(Math.abs(name1.length()-name2.length())/(double)m*100.);
System.out.println("Name: "+n+"% ");
System.out.println("Final: "+(s+a+n)/3+"%");



}
}

--------------------------------------------------------------

import java.util.*;
public class BirthDate
{private int month,day,year;
public BirthDate(int m,int d,int y)
   {month=m;
    day=d;
    year=y;
    }
public int getAge()
{Calendar cal = Calendar.getInstance();
int d,m,y,emonth,eday,eyear;
d = cal.get(Calendar.DATE);
m = cal.get(Calendar.MONTH) + 1;
y = cal.get(Calendar.YEAR);
   if(m>month)
     return y-year;
if(m==month&&d>=day)
     return y-year;
return y-year-1;


}
}