write a program to input the cost price and the selling price of an article . if the selling price is more than the cost price then calculate and display actual profit and profit percent otherwise , calculate and display actual loss and loss percent . if the cost price and the selling price are equal , the programs displays the message neither profit nor loss.
Answers
I hope your day is going well.
I am writing the code in Java.
import java.util.Scanner;class p_l{ public static void main() { Scanner obj=new Scanner(System.in); System.out.println("Enter the cost price."); float cp=obj.nextFloat(); System.out.println("Enter the selling price."); float sp=obj.nextFloat(); System.out.println("Any overhead expenses?\n(If no enter 0.)"); double over=obj.nextDouble(); cp+=over; float net=0; String a; if(cp==sp) System.out.println("Neither profit nor loss."); else { if(cp>sp) { net=cp-sp; System.out.println("The person incurred a loss."); a="loss"; } else { net=sp-cp; System.out.println("The person incurred a profit."); a="profit"; } double per=net/cp*100; System.out.println("The "+a+" is= Rs."+net+"."); System.out.println("The "+a+" percentage is= "+per+"%."); } }}
I hope it helped you.If it did, please mark as brainliest.....
Have a nice day!!!
Good bye!!
Answer:
Explanation:
import java.util.Scanner;class p_l{ public static void main() { Scanner obj=new Scanner(System.in); System.out.println("Enter the cost price."); float cp=obj.nextFloat(); System.out.println("Enter the selling price."); float sp=obj.nextFloat(); System.out.println("Any overhead expenses?\n(If no enter 0.)"); double over=obj.nextDouble(); cp+=over; float net=0; String a; if(cp==sp) System.out.println("Neither profit nor loss."); else { if(cp>sp) { net=cp-sp; System.out.println("The person incurred a loss."); a="loss"; } else { net=sp-cp; System.out.println("The person incurred a profit."); a="profit"; } double per=net/cp*100; System.out.println("The "+a+" is= Rs."+net+"."); System.out.println("The "+a+" percentage is= "+per+"%."); } }}
Read more on Brainly.in - https://brainly.in/question/2175060#readmore