Below Is The Love Program Written in c++, I tried it writing with Java But, didnt understood to Do. WIll Anyone Help me Please

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
int FindPER(char [],int);
void main()
{
int len,i,PER;  char n[100],sen[200];
clrscr();
cout<<"\n Your Name>";   cin>>n;
strcpy(sen,n);        strcat(sen,"LOVES");
cout<<"\n Your Partners Name>";   cin>>n;
strcat(sen,n);        len=strlen(sen);
for(i=0;i<len;i++)    sen[i]=toupper(sen[i]);
PER=FindPER(sen,len);
cout<<"\n> The Percentage Is(Designed By Sahil)"<<PER;
getch();
}
int FindPER(char sen[],int len)
{
char c;
int i,j,a[60],al=-1,s,at[60],per;
for(i=0;i<len;i++)
{
if(sen[i]!='#')
{
c=sen[i]; al=al++;
s=1;sen[i]='#';
}
else
{
c='^';
}
for(j=i;j<len;j++)
{
if(c==sen[j])
{
s++; sen[j]='#';
}
}
a[al]=s;
}
while(al>2)
{
if(al%2==0)
{
j=al-1;
for(i=0;i<(al/2);i++)
{
at[i]=a[i]+a[j];j--;
}
al=i;
for(i=0; i<=al;i++) a[i]=at[i];
}
else
{
j=al-1;
for(i=0;i<(al/2);i++)
{
at[i]=a[i]+a[j];j--;
}
at[i++]=a[i];   al=i;
for(i=0;i<al;i++)  a[i]=at[i];
}
}
if(a[1]<10) per=(a[0]*10)+a[1];
while(per>100)
{
i=per%100;          j=i/10;
s=i%10;             i=per/100;
per=((i+s)*10)+j;
}
return per;
}

Recommended Answers

All 11 Replies

This is the Java section.
Also, post your code in CODE-tags.
Also, include the problem you are having plus any errors that you receive.
You also haven't stated what a "Love Program" is, what is its purpose? Is it doing what you want?

And wow, you use .h in all of your pre-processor declarations, you are using conio.h?? In 2011??? And I also see a void main() which isn't really the standard in C++.

String name=myname.getText();
String name2=partnersname.getText();

After this will you please tell me how can i check love percentage between two name.

String name=myname.getText();
String name2=partnersname.getText();

After this will you please tell me how can i check love percentage between two name.

What on earth are you talking about?

Calculate Love Percentegae . Between two names

Calculate Love Percentege . Between two names

The algorithm is in the c++ program that you copied and posted here. You can read it from there.

The algorithm is in the c++ program that you copied and posted here. You can read it from there.

but i didnt understood how we can write it in Java

but i didnt understood how we can write it in Java

Then learn, but don't expect us to do it for you. The code is there

when you guys will help then so, i can
please

when you guys will help then so, i can
please

You have the code already written. Open any book with java and look at the syntax. Java is similar with C. If you written that code on your own you shouldn't have a problem. If you copied it from somewhere else why should we help you cheat.

Also we only give help to those that show effort. So far you have shown no effort.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.