JAVASCRIPT. Write a script using a function that accepts principle , rate and time from the user and prints the simple intrest.
Accept a number and send it as an argument to function that calculates and displays its square and cube.
plz answer . its my assignment
Answers
Answered by
3
Question:-
Write a script using a function that accepts principle , rate and time from the user and prints the simple intrest.
Code:-
class Interest
{
public static void main(int principal,int rate ,int time)
{
double Interest=principal*rate*time/100;
System.out.println(Interest);
}
}
__________________________________
Question:-
Accept a number and send it as an argument to function that calculates and displays its square and cube.
Code:-
class Squre
{
void calculate(int n)
{
int squr=(int)Math.pow(n,2);
int cube=(int)Math.pow(n,3);
System.out.println("Squre:-"+squr);
System.out.println("Cube:-"+cube);
}
public static void main (int k)
{
Squre obj=new Squre();
obj.calculate(k);
}
}
_____________________________
Similar questions