Beruflich Dokumente
Kultur Dokumente
*;
class patt
{
public static void main(String[] args)
{
int r,c;
for(r=1;r<=5;r++)
{
for(c=1;c<=r;c++)
{
System.out.print(" "+c);
}
System.out.println();
}
}
}
import java.util.*;
class patt
{
public static void main(String[] args)
{
int r,c;
for(r=1;r<=5;r++)
{
for(c=1;c<=r;c++)
{
System.out.print(" "+r);
}
System.out.println();
}
}
}
import java.util.*;
class patt
{
public static void main(String[] args)
{
int r,c;
for(r=1;r<=5;r++)
{
for(c=1;c<=r;c++)
{
System.out.print(" * ");
}
System.out.println();
}
}
}
Question :- WAP to enter principle,rate and time .Calculate the simple Interest and
Compound Interest
import java.util.*;
class patt
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
double p,r,t,si,ci;
System.out.print("Enter principle amount ");
p=sc.nextDouble();
System.out.print("Enter rate of interest ");
r=sc.nextDouble();
System.out.print("Enter rate of Time
");
t=sc.nextDouble();
si=(p*r*t)/100;
ci= p+Math.pow((1+r/100),t)-p;
System.out.println("Simple Interest
"+si);
System.out.println("Compound Interest "+ci);
}
}
"+x);
"+sum);
");
{
System.out.print("\n "+n[i]);
if(num==n[i])
f++;
}
System.out.println("\n frequency of a given number is
}
}
"+f);
Create two arrays of 10 element and find sum of both array in third array
import java.io.*;
class array
{
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n[] = new int[10];
int m[] = new int[10];
int s[] = new int[10];
int i;
for(i=0;i<=9;i++)
{
System.out.print("Enter number of first array ");
n[i]=Integer.parseInt(br.readLine());
}
for(i=0;i<=9;i++)
{
System.out.print("Enter number of second array ");
m[i]=Integer.parseInt(br.readLine());
}
for(i=0;i<=9;i++)
{
s[i]=n[i]+m[i];
System.out.print("\n "+n[i]+"\t"+m[i]+"\t"+s[i]);
}
}
}
");