write a program in Java using a method discount to display a single discount or a successive discount use overload methods discount (int)discount( int int)and discount (int int int) to calculate single discount and successive discount respectively calculate and display the amount to be paid by the customer after getting discounts on the printed price of an article
Answers
Answer:as explained
Explanation:
In function overloading we have to pass as many required actual parameters through same prototype of a given function and they are executed via object when they are called by formal parameters matching with the function prototype.
We will explain the things by code.
class customerDiscount()
{
private:
int a,b,c;
public:
discount(a) ;
discount(a,b) ;
discount(a,b,c) ;
};
public void discount(a)
{
int sp=0,n;
System.out.print("Enter cost price ") ;
n=sc.nextInt() ;
sp=n-n*(a/100)
System.out.print(sp) ;
}
public void discount(a,b)
{
int sp=0,n,sp1=0;
System.out.print("Enter cost price ") ;
n=sc.nextInt() ;
sp=n-n*(a/100);
sp1=sp-sp*(b/100) ;
System.out.print(sp1) ;
}
public void discount(a,b,c)
{
int sp=0,n,sp1=0,sp2=0;
System.out.print("Enter cost price ") ;
n=sc.nextInt() ;
sp=n-n*(a/100);
sp1=sp-sp*(b/100) ;
sp2=sp1-sp*(c/100) ;
System.out.print(sp2) ;
}
Now in the main if we create an object of class operation as s and we call s.discount(n) this will invoke the sum function to call digits as the formal parameters matches the actual parameters.
If we call s.discount(a, b) this will invoke the sum function where two discount will be applied
b) A piece of stone tied at the end of a thread is whirled in a horizontal circle with a uniform speed with
the help of hand. Answer the following questions :
i) Is the velocity of stone uniform are variable ?
ii) Is the acceleration of a stone uniform or variable ?
iii) What is the direction of acceleration of stone at any instant ?
iv)What force does provide the centripetal force required for circular motion?