Design using programming language
Hey!! guys here is the code to java HEART PATEREN
public class HeartPattern
{
public static void main(String[] args)
{
final int size = 4;
for (int m =0; m<size;m++)
{
for(int n=0;n<4*size;n++)
{
double pos1=Math.sqrt(Math.pow(m - size, 2) + Math.pow(n-size,2));
double pos2=Math.sqrt(Math.pow(m - size, 2) + Math.pow(n-3*size,2));
if(pos1<size+0.5 || pos2<size+0.5)
{
System.out.print('*');
}
else
{
System.out.print(' ');
}
}
System.out.print(System.lineSeparator());
}
{
public static void main(String[] args)
{
final int size = 4;
for (int m =0; m<size;m++)
{
for(int n=0;n<4*size;n++)
{
double pos1=Math.sqrt(Math.pow(m - size, 2) + Math.pow(n-size,2));
double pos2=Math.sqrt(Math.pow(m - size, 2) + Math.pow(n-3*size,2));
if(pos1<size+0.5 || pos2<size+0.5)
{
System.out.print('*');
}
else
{
System.out.print(' ');
}
}
System.out.print(System.lineSeparator());
}
and make sure your using JAVA latest Version!!!
python heart :
Comments
Post a Comment